@param array|null $config
@param array|null $data

@return Repository\ModelRepository
337346
public function getModelRepository($config = null, $data = null)
    {
        return new Repository\ModelRepository($this->getRequest(), $config, $data);
    }
959076
public static function newInstance($name, $data = null)
  {
    if (!is_array($data)) {
      $data = array();
    }

    $config = self::getInstance($name);
    $config->_data = $data;

    return $config;
  }
214501
public function buildPDO(array $config=null) {
		if(!$config)
			$config = $this->config;
		$driver = $config['driver'];
		$user = isset($config['user']) ? $config['user']:'root';
		$password = isset($config['password']) ? $config['password']:'';
		$database = isset($config['database']) ? $config['database']:null;

		switch($driver) {
			case 'pgsql':
				$parameters = 'pgsql:host='.$config['host'].(isset($config['port']) ? ' port='.$config['port']:'').($database ? ' dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password);
				break;
			case 'mssql':
				$parameters = 'mssql:host='.$config['host'].($database ? ';dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password);
				break;
			case 'sqlite':
				$pdo = $this->pdo = new \PDO('sqlite:'.$database);
	
				require_once __DIR__.'/sqlite_functions.php';

				break;
			default:
				$parameters = 'mysql:host='.$config['host'].(isset($config['port']) ? ';port='.$config['port']:'').($database ? ';dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password, [\PDO::MYSQL_ATTR_FOUND_ROWS => true, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
		}
		$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
	}
596673
public function model($name, $config = [])
    {
        $config["class"] = $this->modelClasses[ucfirst($name)];
        return Yii::createObject($config);
    }
1132006
public function findOrAddNew($data = array(), $config = array())
    {
        $entity = $this->find($data);

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

        return $entity;
    }
1089753
public function save($data = null, array $options = []) {
        if ($data) {
            $this->data($data);
        }

        return $this->getRepository()->save($this, $options);
    }
61727
public function make($data = null)
    {
        if (is_null($data)) {
            return new NullResource();
        } elseif (is_array($data)) {
            return static::makeFromArray($data);
        }

        $method = static::getMakeMethod($data);

        return static::$method($data);
    }
1044685
public function connect(array $config)
    {
        $options = $this->options($config);

        // SQLite provides supported for "in-memory" databases, which exist only for
        // lifetime of the request. These are mainly for tests.
        if ($config['database'] == ':memory:') {
            return new \Pimf\Database('sqlite::memory:', null, null, $options);
        }

        return new \Pimf\Database('sqlite:' . $config['database'], null, null, $options);
    }
391541
public static function loadConfig($config = null)
    {
        if ($config !== null) {
            Configure::write('CakeResque', $config);
        }

        if (
            ($hasCheck = method_exists('Configure', 'check')) && !Configure::check('CakeResque') ||
            !$hasCheck && !self::checkConfig('CakeResque')
        ) {
            Configure::load('CakeResque.config');
        }
    }
1334112
public function loadArray(array $options, Config $config = null)
    {
        Assertion::notEmpty($options);

        if (is_null($config)) {
            $config = new Config();
        }

        $options = $this->doReplacements($options);

        $config->merge(
            new Config($options)
        );

        return $config;
    }
1057933
protected function createPartOfStructure(array $config)
  {
    $return_properties    = array();
    $return_configuration = array();

    foreach ($config as $configuration)
    {
      $value = null;
      switch ($configuration->getType())
      {
        case TypeEnum::COLLECTION_TYPE:
          $value = array($this->createPartOfStructure($configuration->getChildren()));
          break;
        case TypeEnum::OBJECT_TYPE:
          $value = $this->createPartOfStructure($configuration->getChildren());
          break;
        case TypeEnum::ARRAY_TYPE:
          $value = array();
          break;
        default:
          break;
      }
      $this->modifyConfiguration($configuration);
      $parameter = new Parameter($configuration->getKey(), $value);

      $return_properties[$configuration->getKey()]    = $parameter;
      $return_configuration[$configuration->getKey()] = $configuration;
    }

    return $this->classBuilder->build('\stdClass', $return_configuration, $return_properties);
  }
60876
public static function insert($table, $data = array(), $config = array()) {
        DB::connect();
        return DB::$connection->insert($table, $data, $config);
    }
493043
protected function createFilter(array $data = null)
    {
        $filter = new static();
        if ($data !== null) {
            $filter->setData($data);
        }
        return $filter;
    }
928442
public function fromData(array $data): ModuleConfiguration
    {
        $moduleConfiguration = new ModuleConfiguration();
        $moduleConfiguration
            ->setId($data['id'])
            ->setAutoActive($data['autoActive'])
            ->setTitle($data['title'])
            ->setDescription($data['description'])
            ->setLang($data['lang'])
            ->setThumbnail($data['thumbnail'])
            ->setAuthor($data['author'])
            ->setUrl($data['url'])
            ->setEmail($data['email'])
        ;

        if (isset($data['settings'])) {
            $this->setSettings($moduleConfiguration, $data['settings']);
        }

        return $moduleConfiguration;
    }
40658
public function getConfigData($data = null) {
        if ($data !== null && isset($this->_config[$data])) {
            return $this->_config[$data];
        } elseif ($data === null) {
            return $this->_config;
        } else {
            throw new ConfigException("Error while requesting config value: " . $data);
        }
    }
106371
public function addFromConfig(array $config)
    {
        foreach ($config as $name => $data) {
            $params     = isset($data['params']) ? $data['params'] : array();
            $parameters = array();
            foreach ($params as $nameParam => $param) {
                if (empty($params['type'])) {
                    $params['type'] = 'string';
                }

                switch ($param['type']) {

                    case 'int':
                        $param['type'] = Parameter::TYPE_INTEGER;
                        break;

                    case 'mixed':
                        $param['type'] = Parameter::TYPE_MIXED;
                        break;

                    case 'string':
                        $param['type'] = Parameter::TYPE_STRING;
                        break;

                    default:
                        // Consider  current value as regexp
                }
                $parameters[$nameParam] = new Parameter($nameParam, $param['type'], (bool) $param['mandatory']);
            }
            $this->add(new Route($name, $data['route'], $data['controller'], $parameters));
        }

        return $this;
    }
304462
protected function newRepository(ResourceConfiguration $config)
    {
        if ($this->database instanceof EntityManager) {
            return $this->newDoctrineRepository($this->database, $config->getEntityClass(), $config->getParent());
        } elseif ($this->database instanceof PDO) {
            return $this->newPdoRepository($this->database, $config->getResource(), $config->getParent());
        }

        throw new \Exception("Couldn't determine database connection type.");
    }