Generate the slugs

@param array $args
@return bool
424931
public function generate(array $args = array()) {
        if (empty($args)) {
            $this->help();
            return false;
        }
        $modelName = $args[0];
        if (strpos($modelName, '_') === false) {
            $modelName = 'Model_' . $modelName;
        }
        $overwrite = !empty($args[1]) ? $args[1] : false;

        $model = new $modelName();
        // No reason to cache queries. Use live data.
        $model->setCacheQueries(false);

        // Fetch Sluggable thru the model as to use the right slug-configuration
        list($sluggable, $model) = $this->_resolveSluggableBehavior($model);
        if (is_null($sluggable)) {
            Garp_Cli::errorOut('This model is not sluggable.');
            return false;
        }

        // Array to record fails
        $fails = array();
        $records = $model->fetchAll();
        foreach ($records as $record) {
            if (!$overwrite && $record->slug) {
                continue;
            }
            // Mimic a beforeInsert to create the slug in a separate array $data
            $args = array($model, $record->toArray());
            $sluggable->beforeInsert($args);

            // Since there might be more than one changed column, we use this loop
            // to append those columns to the record
            foreach ($args[1] as $key => $value) {
                if ($value != $record->{$key}) {
                    $record->{$key} = $value;
                }
            }

            // Save the record with its slug
            if (!$record->save()) {
                $pk = implode(', ', (array)$record->getPrimaryKey());
                $fails[] = $pk;
            }
        }

        Garp_Cli::lineOut('Done.');
        if (count($fails)) {
            Garp_Cli::errorOut(
                'There were some failures. ' .
                'Please perform a manual check on records with the following primary keys:'
            );
            Garp_Cli::lineOut(implode("\n-", $fails));
        }
        return true;
    }
588627
public function run($args)
    {
        if (!isset($args[0]) || !$args[0]) {
            return "> Producer: Project directory required.\n";
        }

        $name = trim($args[0]);
        if (!is_dir($path = $this->cwd.'/repository/'.$name)) {
            return "> Producer: Project directory 'repository/{$name}' not found.\n";
        }

        echo $this->info("Reset progect '{$name}'");

        $repo = trim($this->exec('reset-origin', [$path]));

        $purge = new PurgeCommand($this->cwd);
        echo $purge->run([$name]);

        $clone = new CloneCommand($this->cwd);
        echo $clone->run([$repo, $name]);
    }
20296
public function url( array $args = [] ) {
		$url = get_author_posts_url( $this->ID );
		if ( $args ) {
			$url = add_query_arg( $args, $url );
		}

		return $url;
	}
932470
protected function render(Args $args)
    {
        $format = $this->registry->get(
            sprintf(
                'format/%s/%s',
                $this->registry->get('env'),
                self::$reverseLevel[$args->get('level')]
            ),
            self::DEFAULT_FORMAT
        );
        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5);
        $message = str_replace(
            [
                '%DATE%',
                '%TIME%',
                '%LEVEL%',
                '%SOURCE%',
                '%FILE%',
                '%LINE%',
                '%MESSAGE%',
            ],
            [
                date('Y-m-d'),
                date('H:i:s'),
                self::$levelToString[$args->get('level')],
                $args->get('source'),
                $backtrace[4]['file'],
                $backtrace[4]['line'],
                $args->get('message')
            ],
            $format
        );

        return $message;
    }
751389
protected function executeCommand($args)
    {
        $io = clone $this->io;

        $io->setArguments($args);
        $io->setOption('no-backup', true);
        $io->setOption('no-create-database', true);

//        foreach ($this->io->getOptions() as $k => $v)
//        {
//            $io->setOption($k, $v);
//        }

        return $this->console->getRootCommand()->setIO($io)->execute();
    }
1213460
public function run($args)
    {
        $args = $this->parseArgs($args);
        foreach ($this->options as $argument => $attribute) {
            $this->{$attribute} = in_array($argument, $args);
            if ($this->{$attribute}) {
                $args = array_values(array_diff($args, [$argument]));
            }
        }

        if (!isset($args[0]) || !$args[0]) {
            return $this->initPath($this->cwd);
        }

        $projectName = $args[0];
        if (!$this->existsProjectName($projectName)) {
            return "> Producer: Project '{$this->projectsDir}/{$projectName}' not found.\n";
        }

        return $this->initPath($this->getProjectDir($projectName));
    }
679908
private function cmdClone($args)
    {
        $cmd = new CloneCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
333843
public static function generateSlug(string $slug, array $usedSlugs)
    {
        $slug = camel_case($slug);
        $count = 1;

        // adds a number in the slug string if the specific slug allready exists
        if (in_array($slug, $usedSlugs)) {
            while(true){
                $slug = camel_case($slug."_".$count);
                if (!in_array($slug, $usedSlugs)) {
                    return $slug;
                }
                $count++;
            }
        }

        return $slug;
    }
61617
protected function encodeContent(array $args) {
        $data = [];
        foreach ($args as $key => $item) {
            $data[] = sprintf('"%s":"%s"', $key, $item);
        }
        $arg = '{'.implode(',', $data).'}';
        if (!empty($this->encryptKey)
            && $this->encryptType == self::AES) {
            return (new Aes($this->encryptKey))->encrypt($arg);
        }
        return $arg;
    }
309506
private function cmdCheck($args)
    {
        $cmd = new CheckCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
686914
protected function serializeArguments(array $args)
    {
        // first we have to sort the args by key to avoid that different orders
        // lead to different cache entries!
        ksort($args);

        $result = '';
        $invalidKeys = array('userid', 'apikey', 'keyid', 'vcode');
        foreach ($args as $key => $value) {
            $key   = trim($key);
            $value = trim($value);
            if (empty($value) || in_array($key, $invalidKeys)) {
                // ignore the invalid keys...
                continue;
            }
            $result .= ';' . $key . '=' . $value;
        }

        return $result;
    }
399453
protected function make($slug, $arguments = [])
    {
        $sidebar = $this->container->make(Sidebar::class);

        $sidebar
            ->setSlug($slug)
            ->setArguments($arguments)
            ->boot();

        return $this->hang($sidebar);
    }
418807
public function make(array $args = array()) {
        $userModel = new Model_User();
        if (!empty($args)) {
            $id = $args[0];
        } else {
            $id = Garp_Cli::prompt('What is the id or email address of the user?');
        }
        $select = $userModel->select();
        if (is_numeric($id)) {
            $filterColumn = 'id';
        } else {
            $filterColumn = 'email';
        }
        $select->where($filterColumn . ' = ?', $id);
        $user = $userModel->fetchRow($select);
        if (!$user) {
            Garp_Cli::errorOut('Error: could not find user with ' . $filterColumn . ' ' . $id);
        } else {
            $user->role = 'admin';
            if ($user->save()) {
                // For completeness sake, check if the user has an AuthLocal
                // record. We disregard the fact wether the user already has any
                // of the other Auth- records.
                $authLocalModel = new Model_AuthLocal();
                $authLocalRecord = $authLocalModel->fetchRow(
                    $authLocalModel->select()->where('user_id = ?', $user->id)
                );
                if (!$authLocalRecord) {
                    $newAuthLocalData = array(
                        'password' => trim(Garp_Cli::prompt('Choose a password:')),
                        'user_id'  => $user->id
                    );
                    $authLocalModel->insert($newAuthLocalData);
                }
                Garp_Cli::lineOut(
                    'User with ' . $filterColumn . ' ' . $id .
                    ' is now administrator'
                );
            } else {
                Garp_Cli::errorOut(
                    'Error: could not make user with ' . $filterColumn . ' ' . $id .
                    ' administrator'
                );
            }
        }
    }
332338
protected function setParams(array $args)
    {
        if (!empty($args)) {
            $request = '?';
        } else {
            $request = '';
        }

        foreach ($args as $key => $value) {
            if (is_numeric($key)) {
                if ($request != '?') {
                    $request .= '&';
                }
                $request .= $value;
            } elseif (is_string($key)) {
                if ($request != '?') {
                    $request .= '&';
                }
                $request .= $key.'='.$value;
            }
        }

        return $request;
    }
105917
private function cmdPurge($args)
    {
        $cmd = new PurgeCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
156123
public function url( array $args = []) {
		$url = get_term_link( $this->term );
		if ( $args ) {
			$url = add_query_arg( $args, $url );
		}

		return $url;
	}
969931
public static function evaluateArgs(array $args)
    {

        $parsedArgs = [];

        foreach ($args as $key=>$value) {

            if ($value instanceof self) {
                $parsedArgs[$key] = static::callFast($value);
                continue;
            }
            $parsedArgs[$key] = $args[$key];
        }

        return $parsedArgs;

    }