Creates a Plot working like a Plot Factory.
@access		protected
@static
@param		array		$config			Configuration Data
@param		array		$data			Graph Data
@param		string		$prefix			Configuration Prefix, must end with a Point
@return		mixed
505529
protected static function createPlot( $config, $data, $prefix )
	{
		$plotClass	= $config[$prefix.'type'];
		$plotClass	= 'UI_Image_Graph_'.$plotClass;
		$plotObject	= new $plotClass;
		$plotConf	= self::getSubConfig( $config, $prefix );
		return $plotObject->buildPlot( $plotConf, $data );
	}
466372
protected function createPdoResolverWithHosts( array $config )
	{
		return function () use ( $config ) {

			foreach( Arr::shuffle( $hosts = $this->parseHosts( $config ) ) as $key => $host )
			{
				$config['host'] = $host;
				try
				{
					return $this->createConnector( $config )->connect( $config );
				}
				catch( PDOException $e )
				{
					if( count( $hosts ) - 1 === $key )
					{
						App::Log($e);
					}
				}
			}

			if(!isset($e)) {
				$e = new PDOException("Empty connection");
			}

			throw $e;
		};
	}
745066
protected function createTemplater($pattern, $data, $prefix)
    {
        return (new Templater($this->connector, $pattern, $data, $prefix));
    }
977835
protected function createDatabaseDriver(array $config)
    {
        $connection = $this->app['db']->connection(Arr::get($config, 'connection'));

        return $this->repository(
            new DatabaseStore(
                $connection, $config['table'], $this->getPrefix($config)
            )
        );
    }
375940
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
    {
        if ($this->container->bound($key = "db.connection.{$driver}")) {
            return $this->container->make($key, [$connection, $database, $prefix, $config]);
        }

        switch ($driver) {
            case 'mysql':
                return new MySqlConnection($connection, $database, $prefix, $config);

            case 'pgsql':
                return new PostgresConnection($connection, $database, $prefix, $config);
        }

        return parent::createConnection($driver, $connection, $database, $prefix, $config);
    }
1143557
public static function createEmptyFromConfig(array $config)
    {
        $manager = new self();

        if (isset($config['base_uri'])) {

            $manager->setBaseUri($config['base_uri']);
        }

        if (isset($config['path'])) {

            $manager->setBasePath($config['path']);
        }

        if (isset($config['path_aliases']) && is_array($config['path_aliases'])) {

            foreach ($config['path_aliases'] as $alias => $path) {

                $manager->addPathAlias($alias, $path);
            }   
        }

        if (isset($config['compiled'])) {

            $manager->setCompileDirectory($config['compiled']);
        }

        if (isset($config['version'])) {

            $manager->setVersion($config['version']);
        }

        return $manager;
    }
461088
public static function factory($config = array())
    {
        $default = array(
            'base_url' => 'https://api.runkeeper.com',
            'logger' => FALSE,
        );
        $required = array('base_url');

        $config = Collection::fromConfig($config, $default, $required);

        $client = new self($config->get('base_url'));
        $client->setConfig($config);

        $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));

        // Set the iterator resource factory based on the provided iterators config
        $clientClass = get_class();
        $prefix = substr($clientClass, 0, strrpos($clientClass, '\\'));
        $client->setResourceIteratorFactory(
            new HealthGraphIteratorFactory(array("{$prefix}\\Common\\Iterator"))
        );

        if ($config->get('logger')) {
            $adapter = new \Guzzle\Log\PsrLogAdapter($config->get('logger'));
            $logPlugin = new \Guzzle\Plugin\Log\LogPlugin(
                $adapter,
                \Guzzle\Log\MessageFormatter::DEBUG_FORMAT
            );
            $client->addSubscriber($logPlugin);
        }

        return $client;
    }
1080012
public static function getSubConfig( $config, $prefix )
	{
		$data	= array();
		$length	= strlen( $prefix );
		foreach( $config as $key => $value )
			if( substr( $key, 0, $length ) == $prefix )
				$data[substr( $key, $length )]	= $value;
		return $data;
	}
825028
public function pagination($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'total'      => 0,
            'display'    => 2,
            'offset'     => 0,
            'limit'      => 0,
            'show_limit' => true,
            'show_count' => false
        ))->append(array(
            'show_pages' => $config->count !== 1
        ));

        $this->_initialize($config);

        $html = '<div class="k-pagination">';

        if($config->show_limit) {
            $html .= '<div class="k-pagination__limit">'.$this->limit($config).'</div>';
        }

        if ($config->show_pages)
        {
            $html .= '<ul class="k-pagination__pages">';
            $html .=  $this->_pages($this->_items($config));
            $html .= '</ul>';
        }

        if($config->show_count)
        {
            $current = '<strong class="page-current">'.$config->current.'</strong>';
            $total   = '<strong class="page-total">'.$config->count.'</strong>';

            $html .= '<div class="k-pagination-pages">';
            $html .= sprintf($this->getObject('translator')->translate('Page %s of %s'), $current, $total);
            $html .= '</div>';
        }

        $html .= '</div>';

        return $html;
    }
735881
public static function factory($config = array())
    {
        $defaults = array(
            'base_url' => 'http://localhost:8983',
            'base_path' => '/solr',
            'max_query_length' => self::MAX_QUERY_LENGTH,
        );

        $required = array(
            'base_url',
            'base_path',
            'max_query_length',
        );

        // Instantiate and return the Solr client.
        $config = Collection::fromConfig($config, $defaults, $required);
        $solr = new static($config->get('base_url'), $config);

        // Use URI template expansion in a way that doesn't break Solr.
        $solr->setUriTemplate(new SolrUriTemplate());

        // Use JSON whenever possible.
        // @see http://code.google.com/p/solr-php-client/issues/detail?id=6#c1
        $jsonParams = array(
            'wt'      => 'json',
            'json.nl' => 'map',
        );

        // Sometimes we have to use XML :-(.
        $xmlParams = array(
            'wt' => 'xml',
        );

        $solr
            ->setRequestHandler(new RequestHandler('luke',    'admin/luke',      'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('mbeans',  'admin/mbeans',    'GET',  $xmlParams + array('stats' => 'true')))
            ->setRequestHandler(new RequestHandler('mlt',     'mlt',             'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('ping',    'admin/ping',      'HEAD', $jsonParams))
            ->setRequestHandler(new RequestHandler('select',  'select',          'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('spell',   'spell',           'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('stats',   'admin/stats.jsp', 'GET',  $xmlParams))
            ->setRequestHandler(new RequestHandler('suggest', 'suggest',         'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('system',  'admin/system',    'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('update',  'update',          'POST', $jsonParams))
        ;

        return $solr;
    }
630292
public function process(array $data, array $config)
	{
		// Intersect the data given the with the data keys provided.
		$specifiedData = array_intersect_key($data, array_flip(array_keys($config)));

		// Validate and set our errors if they exist.
		$this->errorPayload = $this->validator->validate($specifiedData, $config);

		// Return sanitized data if no validation errors exist.
		if($this->errorPayload->getStatus() == Payload::STATUS_VALID)
		{
			return new Payload($specifiedData, Payload::STATUS_VALID);
		}

		return $this->errorPayload;
	}
1269160
public static function toPHPString($config, $prefix = ""){
        $r = [];

        foreach ($config as $key=>$value){
            if (is_int($key)){
                $line = $prefix . self::$tabContent;
            } else {
                $key = addslashes($key);
                $line = $prefix . self::$tabContent . "\"$key\" => ";
            }
            if (is_string($value)){
                $value = addslashes($value);
                $line .= "\"$value\"";
                $r[] = $line;
                continue;
            } elseif (is_bool($value)){
                $line .= ($value?"true":"false");
                $r[] = $line;
                continue;
            } elseif (is_int($value)){
                $line .= "$value";
                $r[] = $line;
                continue;
            }
            $line .= "[\n" .
                implode(",\n", self::toPHPString($value, $prefix.self::$tabContent))
                . "\n$prefix".self::$tabContent."]";
            $r[] = $line;
        }

        return $r;
    }
438112
public function process(array $data, array $config)
	{
		// Merge default or built-in configurations.
		$config = array_merge($this->config, $config);

		// Intersect the data given the with the data keys provided.
		$data = array_intersect_key($data, array_flip(array_keys($config)));

		// Validate and set our errors if they exist.
		$payload = $this->validator->validate($data, $config);

		// Return sanitized data if no validation errors exist.
		if( ! $payload->isStatus(Payload::STATUS_VALID))
		{
			return $payload;
		}

		// Grab payload data for more modification.
		$data = $payload->getData();

		if(array_key_exists(CrudRepository::PAGE_KEY, $data) && array_key_exists(CrudRepository::PER_KEY, $data))
		{
			$data[CrudRepository::PAGINATION_KEY] = [$data[CrudRepository::PAGE_KEY] => $data[CrudRepository::PER_KEY]];
		}

		if(array_key_exists(CrudRepository::FILTER_KEY, $data))
		{
			$data[CrudRepository::FILTER_KEY] = $data[CrudRepository::FILTER_KEY];
		}

		if(array_key_exists(CrudRepository::ORDER_KEY, $data))
		{
			$data[CrudRepository::ORDER_KEY] = $data[CrudRepository::ORDER_KEY];
		}

		if(array_key_exists(CrudRepository::EMBED_KEY, $data))
		{
			$data[CrudRepository::EMBED_KEY] = $data[CrudRepository::EMBED_KEY];
		}

		return new Payload($data, Payload::STATUS_VALID);
	}
104763
public function createOssAdapter(array $config)
    {
        $root = $config['root'] ?? null;
        $oss = new OssClient($config['access_id'], $config['access_secret'], $config['endpoint'],
            $config['isCName'] ?? false,
            $config['securityToken'] ?? null,
            $config['proxy'] ?? null
        );
        $oss->setTimeout($config['timeout'] ?? 3600);
        $oss->setConnectTimeout($config['connectTimeout'] ?? 10);
        $oss->setUseSSL($config['useSSL'] ?? false);
        return $this->adapt($this->createFlysystem(
            new OssAdapter($oss, $config['bucket'], $root), $config
        ));
    }
1132006
public function findOrAddNew($data = array(), $config = array())
    {
        $entity = $this->find($data);

        if (!$entity) {
            $entity = $this->addNew($data, $config);
        }

        return $entity;
    }
435752
public function addNew($data = array(), $config = array())
    {
        $config = new AnConfig($config);
        $config['data'] = $data;
        $entity = $this->getRepository()->getEntity($config);
        $this->insert($entity);

        return $entity;
    }
298166
public function create(array $data = array())
    {
        if (!isset($data["configPathPrefix"])) {
            $data["configPathPrefix"] = $this->configPathPrefix;
        }
        return $this->_objectManager->create($this->_instanceName, $data);
    }