@param Blendable $blendable
@param string $seed_key
@param string $object_type
@param string $seeds_dir
@param bool $overwrite

@return bool
508623
protected function blendOneFromMany($blendable, $seed_key, $object_type, $seeds_dir, $overwrite = false)
    {
        if (!empty($seeds_dir)) {
            $blendable->setSeedsDir($seeds_dir);
        }

        if ($success = $blendable->blendFromSeed($seed_key, $overwrite)) {
            $this->blender->outSuccess($seed_key.' ' . $object_type . ' has been blended into primary key: ' .
                $blendable->getXPDOSimpleObject()->getPrimaryKey());

        } elseif ($blendable->isExists()) {
            $this->blender->outError($seed_key.' ' . $object_type .' already exists');
            if ($this->userInteractionHandler->promptConfirm('Would you like to update?', true)) {
                if ($success = $blendable->blendFromSeed($seed_key, true)) {
                    $this->blender->out($seed_key.' has been blended');
                }
            }

        } else {
            $this->blender->outError('There was an error saving the ' . $object_type . ' for seed key '. $seed_key);
        }

        return $success;
    }
382140
protected function _generateScaledImagesForTemplate($template, $overwrite = false) {
        Garp_Cli::lineOut('Generating scaled images for template "' . $template . '".');

        $imageModel = new Model_Image();
        $records    = $imageModel->fetchAll();
        $file       = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD);
        $scaler     = new Garp_Image_Scaler();
        $success    = 0;

        foreach ($records as $record) {
            $success += (int)$this->_scaleDatabaseImage(
                $record, $file, $scaler, $template, $overwrite
            );
        }

        Garp_Cli::lineOut('Done scaling images for template "' . $template . '".');
        return $success == count($records);
    }
357715
public function generate(string $projectDir, bool $overwriteSecurity, bool $overwriteLiipImagine, bool $overwriteFosHttpCache, bool $overwriteFosUser)
    {
        $this->renderSingleFile(
            $this->skeletonDir,
            $projectDir . '/config/packages/',
            'security.yaml',
            [],
            true,
            $overwriteSecurity ? 'security.yaml' : 'security.yaml.example'
        );
        $this->renderSingleFile(
            $this->skeletonDir,
            $projectDir . '/config/packages/',
            'liip_imagine.yaml',
            [],
            true,
            $overwriteLiipImagine ? 'liip_imagine.yaml' : 'liip_imagine.yaml.example'
        );
        $this->renderSingleFile(
            $this->skeletonDir,
            $projectDir . '/config/packages/prod/',
            'fos_http_cache.yaml',
            [],
            true,
            $overwriteFosHttpCache ? 'fos_http_cache.yaml' : 'fos_http_cache.yaml.example'
        );
        $this->renderSingleFile(
            $this->skeletonDir,
            $projectDir . '/config/packages/',
            'fos_user.yaml',
            [],
            true,
            $overwriteFosUser ? 'fos_user.yaml' : 'fos_user.yaml.example'
        );
    }
476905
public function merge(DataArrayInterface $dataArray, $overwrite = true)
    {
        foreach ($dataArray as $key => $value) {
            //http://juliusbeckmann.de/blog/php-benchmark-isset-or-array_key_exists.html
            if (isset($this->value[$key])) {
                if (is_int($key)) {
                    $this->value[] = $value;
                } else if ($value instanceof self
                    && $this->value[$key] instanceof self) {
                    $this->value[$key]->merge($value);
                } else if ($overwrite) {
                    if ($value instanceof self) {
                        //new static for php 5.3. late static binding
                        //we need to do this since it is possible we are dealing
                        // with a derived class
                        $this->value[$key] = new static($value->toArray());
                    } else {
                        $this->value[$key] = $value;
                    }
                }
            } else {
                if ($value instanceof self) {
                    $this->value[$key] = new static($value->toArray());
                } else {
                    $this->value[$key] = $value;
                }
            }
        }

        return $this;
    }
263747
public function copy($source, $destination, $override = false)
    {
        if (is_dir($destination) && !is_dir($source)) {
            $destination = rtrim($destination, '/') . '/' . basename($source);
        }
        $this->fs->copy($source, $destination, $override);
    }
1138802
public function revertBlendManyResources($resources = [], $seeds_dir = '')
    {
        $saved = true;
        // will update if resource does exist or create new
        foreach ($resources as $context => $seeds) {

            foreach ($seeds as $seed_key) {
                /** @var \LCI\Blend\Blendable\Resource $blendResource */
                $blendResource = new Resource($this->modx, $this->blender, $this->blender->getAliasFromSeedKey($seed_key), $context);

                if(!$this->revertOneFromMany($blendResource, $seed_key, 'Resource', $seeds_dir)) {
                    $saved = false;
                }
            }

        }

        return $saved;
    }
64432
protected function _process($plugins, $copy = false, $overwrite = false)
    {
        $overwrite = (bool)$this->param('overwrite');

        foreach ($plugins as $plugin => $config) {
            $this->out();
            $this->out('For plugin: ' . $plugin);
            $this->hr();

            if ($config['namespaced'] &&
                !is_dir($config['destDir']) &&
                !$this->_createDirectory($config['destDir'])
            ) {
                continue;
            }

            $dest = $config['destDir'] . $config['link'];

            if (file_exists($dest)) {
                if ($overwrite && !$this->_remove($config)) {
                    continue;
                } elseif (!$overwrite) {
                    $this->verbose(
                        $dest . ' already exists',
                        1
                    );

                    continue;
                }
            }

            if (!$copy) {
                $result = $this->_createSymlink(
                    $config['srcPath'],
                    $dest
                );
                if ($result) {
                    continue;
                }
            }

            $this->_copyDirectory(
                $config['srcPath'],
                $dest
            );
        }

        $this->out();
        $this->out('Done');
    }
314449
public function generateLayout($packageKey, $layoutName, $overwrite = false)
    {
        $layoutName = ucfirst($layoutName);

        $templatePathAndFilename = 'resource://Neos.Kickstarter/Private/Generator/View/' . $layoutName . 'Layout.html';

        $contextVariables = [];
        $contextVariables['packageKey'] = $packageKey;

        $fileContent = $this->renderTemplate($templatePathAndFilename, $contextVariables);

        $layoutFilename = $layoutName . '.html';
        $viewPath = 'resource://' . $packageKey . '/Private/Layouts/';
        $targetPathAndFilename = $viewPath . $layoutFilename;

        $this->generateFile($targetPathAndFilename, $fileContent, $overwrite);

        return $this->generatedFiles;
    }
502032
public function addValue($key, $value, $overwrite = false)
    {
        if (!isset($this->data[$key]) || $overwrite) {
            $this->data[$key] = (string) $value;
        }
    }
394066
public function make($data, $code, $overwrite = false)
    {
        // Status returned.
        $status = (preg_match('/^(1|2|3)/', $code)) ? 'success' : 'error';

        // Change object to array.
        if (is_object($data))
        {
            $data = $data->toArray();
        }

        // Data as a string.
        if (is_string($data))
        {
            $data = array('message' => $data);
        }

        // Overwrite response format.
        if ($overwrite === true)
        {
            $response = $data;
        }
        else
        {
            $message = $this->statuses[$code];

            // Custom return message.
            if (isset($data['message']))
            {
                $message = $data['message'];

                unset($data['message']);
            }

            // Available data response.
            $response = array(
                'status'     => $status,
                'code'       => $code,
                'message'    => $message,
                'data'       => $data,
                'pagination' => null
            );

            // Merge if data has anything else.
            if (isset($data['data']))
            {
                $response = array_merge($response, $data);
            }

            // Remove empty array.
            $response = array_filter($response, function($value)
            {
                return ! is_null($value);
            });

            // Remove empty data.
            if ($this->config['removeEmptyData'] && empty($response['data']))
            {
                unset($response['data']);
            }
        }

        // Header response.
        $header = ($this->config['httpResponse']) ? $code : 200;

        return Response::make($response, $header);
    }
207327
public static function create(string $path, string $content = '', bool $overwrite = true): self
    {
        $path = normalize_path($path);

        if (is_file($path) && $overwrite) {
            self::unlink($path);
        }
        if (!is_file($path)) {
            if (is_writeable(dirname($path))) {
                if ($handle = fopen($path, 'w')) {
                    fwrite($handle, $content);
                    fclose($handle);

                    return new static($path);
                }
                throw new FileException('Creating file ('.$path.') failed');
            }
            throw new FileException('Cannot create file, because the directory ('.dirname($path).') is not accessible',
                FileException::NOT_WRITEABLE);
        }
        throw new FileException('Cannot create file, because the file path ('.$path.') already exist', FileException::ALREADY_EXIST);
    }
401504
public function assign(string $key, $value, bool $overwrite = false)
  {
    $file = $this->file;

    if (file_exists($file)) {
      $data = unserialize($this->decrypt(file_get_contents($file)));

      if (is_array($data)) {
        if (isset($data[$key])) {
          if ($overwrite == true) {
            $data[$key] = $value;
            $data = $this->encrypt(serialize($data));
            return file_put_contents($file, $data);
          }
          return false;
        } else {
          $data[$key] = $value;
          $data = $this->encrypt(serialize($data));
          return file_put_contents($file, $data);
        }
      }
    }

    $data = $this->encrypt(serialize([$key => $value]));

    file_put_contents($file, $data);

    return false;
  }
41107
protected function _generateScaledImagesForId($id, $overwrite = false) {
        if (!$id) {
            return;
        }

        $imageModel = new Model_Image();
        $record     = $imageModel->fetchById($id);
        return $this->_generateScaledImagesForFilename($record->filename);
    }
370348
public function writeContent($content, $overwrite = false)
    {

        if ($overwrite) {
            $fh = fopen($this->getPath(), 'w');
        } else {
            $fh = fopen($this->getPath(), 'w+');
        }
        fwrite($fh, $content);
        fclose($fh);
    }
171724
protected function loadObjectDataFromSeed($seed_key)
    {
        $data = $this->modx->cacheManager->get($seed_key, $this->seedCacheOptions);
        if ($data == false) {
            if ($this->type == 'blend') {
                $this->blender->outError('Error: Seed could not be found: '.$seed_key);
                throw new BlendableException('Error: Seed could not be found: '.$seed_key . ' in '. print_r($this->seedCacheOptions, true));
            }

        } else {
            $this->blendable_xpdo_simple_object_data = $data['columns'];
            $this->unique_key_history = $data['primaryKeyHistory'];
            $this->related_data = $data['related'];
        }

        return $data;
    }
626466
protected function revertOneFromMany($blendable, $seed_key, $object_type, $seeds_dir)
    {
        if (!empty($seeds_dir)) {
            $blendable->setSeedsDir($seeds_dir);
        }

        if ($success = $blendable->revertBlend()) {
            $this->blender->outSuccess($seed_key.' ' . $object_type . ' has been reverted to '.$seeds_dir);

        } else {
            $this->blender->outError($seed_key.' chunk was not reverted');
        }

        return $success;
    }
1095852
public function makeContextSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true)
    {
        $keys = [];
        $collection = $this->modx->getCollection('modContext', $criteria);

        foreach ($collection as $context) {
            /** @var Context $blendContext */
            $blendContext = new Context($this->modx, $this->blender, $context->get('key'));
            $seed_key = $blendContext
                ->setSeedsDir($this->format->getMigrationName('context', $name))
                ->seed();
            $this->blender->out("Context: ".$context->get('name').' Key: '.$seed_key);
            $keys[] = $seed_key;
        }

        if ($create_migration_file) {
            /** @var MigrationsCreator $migrationCreator */
            $migrationCreator = new MigrationsCreator($this->blender->getUserInteractionHandler(), $keys);

            $migrationCreator
                ->setPathTimeStamp($this->format->getPathTimeStamp())
                ->setVerbose($this->blender->getVerbose())
                ->setName($name)
                ->setDescription('')
                ->setServerType($server_type)
                ->setMigrationsPath($this->blender->getMigrationPath())
                ->createContextMigrationClassFile();

            $this->logCreatedSeedMigration($migrationCreator->getLogData());
        }
        return $keys;
    }