@param Profile $profile
@param bool    $clear

@return BackupCollection

@throws \Exception
425569
public function backup(Profile $profile, $clear = false)
    {
        $scratchDir = $profile->getScratchDir();
        $processor = $profile->getProcessor();
        $filesystem = new Filesystem();

        if ($clear) {
            $this->logger->info('Clearing scratch directory...');
            $filesystem->remove($scratchDir);
        }

        if (!is_dir($scratchDir)) {
            $filesystem->mkdir($scratchDir);
        }

        $this->logger->info('Beginning backup...');

        foreach ($profile->getSources() as $source) {
            $source->fetch($scratchDir, $this->logger);
        }

        $filename = $processor->process($scratchDir, $profile->getNamer(), $this->logger);

        try {
            $backups = $this->sendToDestinations($profile, $filename);
        } catch (\Exception $e) {
            $processor->cleanup($filename, $this->logger);

            throw $e;
        }

        $processor->cleanup($filename, $this->logger);
        $this->logger->info('Done.');

        return new BackupCollection($backups);
    }
280973
public function setProfileBanner(\HarvestCloud\CoreBundle\Entity\Image $profileBanner = null)
    {
        $this->profileBanner = $profileBanner;

        return $this;
    }
1298861
public function getLastResult($profileName = null)
    {
        if ($profileName) {
            $this->setProfile($profileName);
        }
        if (!$this->currentProfile) {
            throw new \InvalidArgumentException("No profile set. Cannot run validation.");
        }
        return $this->profiles[$profileName]->getLastResult();
    }
399887
public function getEFTBankAccount( CustomerVault\Profile $profile, CustomerVault\EFTBankaccounts $bankDetails )
    {
        $profile->setRequiredFields(array('id'));
        $profile->checkRequiredFields();
        $bankDetails->setRequiredFields(array('id'));
        $bankDetails->checkRequiredFields();
        $request = new Request(array(
            'method' => Request::GET,
            'uri' => $this->prepareURI("/profiles/" . $profile->id . "/eftbankaccounts/" . $bankDetails->id),
            'body' => $profile
        ));
        $response = $this->client->processRequest($request);
        return new CustomerVault\EFTBankaccounts($response);
    }
1006701
private function sendToDestinations(Profile $profile, $filename)
    {
        $backups = array();

        foreach ($profile->getDestinations() as $destination) {
            $backup = $destination->push($filename, $this->logger);

            $size = $backup->getSize();

            if (class_exists('\\ByteUnits\\System')) {
                $size = \ByteUnits\parse($size)->format('B');
            }

            $this->logger->info(
                sprintf('Backup created for destination "%s" at: "%s" ', $destination->getName(), $backup->getKey()),
                array(
                    'size' => $size,
                    'created_at' => $backup->getCreatedAt()->format('Y-m-d H:i:s'),
                )
            );

            $backups[] = $backup;
        }

        return $backups;
    }
1332981
public function get_profile_fields($field = null, $default = null)
	{
		if (empty($this->user))
		{
			return false;
		}

		if (isset($this->user['profile_fields']))
		{
			is_array($this->user['profile_fields']) or $this->user['profile_fields'] = (@unserialize($this->user['profile_fields']) ?: array());
		}
		else
		{
			$this->user['profile_fields'] = array();
		}

		return is_null($field) ? $this->user['profile_fields'] : \Arr::get($this->user['profile_fields'], $field, $default);
	}
392844
public function persist(ProfileInterface $profile)
    {
        foreach ($this->persistenceHandlers as $persistenceHandler) {
            $persistenceHandler->persist($profile);
        }

        return $this;
    }
1308442
public function addProfile($profileName, $profileDef)
    {
        $this->profiles[$profileName] = $profileDef instanceof \DataFilter\Profile
            ? $profileDef
            : new \DataFilter\Profile($profileDef);
    }
253210
public function makeDirectoryBeforeUpload($path, $cleanDirectory = false)
    {
        if (! $this->exists($path)) {
            $this->makeDirectory($path, 0775, true);
            return true;
        }

        // tamamen silip oluşturmak istendi ise
        if (($this->exists($path) && $cleanDirectory) || (isset($this->options['is_reset']) && $this->options['is_reset'])) {
            $this->deleteDirectory($path, true);
            $this->makeDirectory($path, 0775, true, true);
            return true;
        }

        if ($this->options['relation'] !== 'hasMany' && ( ! isset($this->options['is_reset']) ||  $this->options['is_reset']) ) {
            $this->cleanDirectory($path);
        }
        return true;
    }
971846
protected function registerProfileBuilder()
    {
        $this->app->singleton('backup.builder', function (Container $app) {
            $config = $app['config']['backup'];

            $factory = new ProfileBuilderFactory($app);

            return $factory->make($config);
        });

        $this->app->alias('backup.builder', ProfileBuilder::class);
    }
1147192
protected function setProfile($profile)
	{
		if ( ! is_string($profile) && $profile !== null)
		{
			throw new \InvalidArgumentException('Wrong profile value.');
		}
		
		$this->profile = $profile;
		
		return $this;
	}
550277
public function get(string $profile)
    {
        if (!$this->has($profile)) {
            throw new Exception("Profile {$profile} does not exist.");
        }

        return $this->children[$profile];
    }
720372
public function getBACSBankAccount( CustomerVault\Profile $profile, CustomerVault\BACSBankaccounts $bankDetails )
    {
        $profile->setRequiredFields(array('id'));
        $profile->checkRequiredFields();
        $bankDetails->setRequiredFields(array('id'));
        $bankDetails->checkRequiredFields();
        $request = new Request(array(
            'method' => Request::GET,
            'uri' => $this->prepareURI("/profiles/" . $profile->id . "/bacsbankaccounts/" . $bankDetails->id),
            'body' => $profile
        ));
        $response = $this->client->processRequest($request);
        return new CustomerVault\BACSBankaccounts($response);
    }
469069
public function setProfile(\HarvestCloud\CoreBundle\Entity\Profile $profile = null)
    {
        $this->profile = $profile;

        return $this;
    }
994735
public function profile($profile = null)
    {
        if ($profile === null) {
            return $this->_providerProfile;
        }

        $this->_providerProfile = $profile;
    }
570235
public function setProfile(AccountProfile $profile)
    {
        $request = new SetAccountProfileRequest($this->identifier);
        $request->setProfileItem($profile);
        $response = new SetAccountProfileResponse();
        return $this->client->sendRequest($request, $response);
    }
875569
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        if (false === $this->enabled) {
            return;
        }

        $profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
        $profile->setTime(time());
        $profile->setUrl($request->getUri());
        $profile->setMethod($request->getMethod());
        $profile->setStatusCode($response->getStatusCode());
        try {
            $profile->setIp($request->getClientIp());
        } catch (ConflictingHeadersException $e) {
            $profile->setIp('Unknown');
        }

        if ($prevToken = $response->headers->get('X-Debug-Token')) {
            $response->headers->set('X-Previous-Debug-Token', $prevToken);
        }

        $response->headers->set('X-Debug-Token', $profile->getToken());

        foreach ($this->collectors as $collector) {
            $collector->collect($request, $response, $exception);

            // we need to clone for sub-requests
            $profile->addCollector(clone $collector);
        }

        return $profile;
    }