__construct() public method

The default implementation does two things: - Initializes the object with the given configuration $config. - Call Object::init. If this method is overridden in a child class, it is recommended that - the last parameter of the constructor is a configuration array, like $config here. - call the parent implementation at the end of the constructor.
public __construct ( array $config = [] )
$config array name-value pairs that will be used to initialize the object properties
Example #1
0
 /**
  * @param string|mixed[] $config the configuration of [[\romkaChev\yii2\swiper\Slide]]
  *                               You can create slide just from string
  *                               For example:
  *
  *                               ~~~
  *                                 $slide = new \romkaChev\yii2\swiper\Slide('slide content');
  *                               ~~~
  *
  *
  *                               Also you can create slide from array or strings and
  *                               they will be merged into one string
  *                               For example:
  *
  *                               ~~~
  *                                $slide = new \romkaChev\yii2\swiper\Slide([
  *                                    'content' => [
  *                                        '<h1>Title</h1>',
  *                                        '<h3>Subtitle</h3>',
  *                                        '<p>Main content</p>'
  *                                    ]
  *                                ]);
  *                               ~~~
  *
  * @see \romkaChev\yii2\swiper\Slide::$background
  * @see \romkaChev\yii2\swiper\Slide::$hash
  * @see \romkaChev\yii2\swiper\Slide::$content
  */
 public function __construct($config = [])
 {
     $config = is_string($config) ? [self::CONTENT => $config] : $config;
     $config[self::CONTENT] = ArrayHelper::getValue($config, self::CONTENT, null);
     $config[self::CONTENT] = is_array($config[self::CONTENT]) ? implode('', $config[self::CONTENT]) : $config[self::CONTENT];
     parent::__construct($config);
 }
 /**
  * Costruisce una nuova istanza della classe e imposta le proprietà fondamentali.
  * @param type $id Id applicazione
  * @param type $basePath Cartella root dell'applicazione
  * @param type $filesSubfolder Sottocartella per i files di configurazione
  */
 public function __construct($id, $basePath, $filesSubfolder = null)
 {
     $this->_id = $id;
     $this->_basePath = $basePath;
     $this->_configFolder = dirname(__FILE__) . '/../../../config/' . ($filesSubfolder ? $filesSubfolder . '/' : '');
     parent::__construct();
 }
Example #3
0
 /**
  * @param \phpDocumentor\Reflection\BaseReflector $reflector
  * @param Context $context
  * @param array $config
  */
 public function __construct($reflector = null, $context = null, $config = [])
 {
     parent::__construct($config);
     if ($reflector === null) {
         return;
     }
     // base properties
     $this->name = ltrim($reflector->getName(), '\\');
     $this->startLine = $reflector->getNode()->getAttribute('startLine');
     $this->endLine = $reflector->getNode()->getAttribute('endLine');
     $docblock = $reflector->getDocBlock();
     if ($docblock !== null) {
         $this->shortDescription = ucfirst($docblock->getShortDescription());
         if (empty($this->shortDescription) && !$this instanceof PropertyDoc && $context !== null && $docblock->getTagsByName('inheritdoc') === null) {
             $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No short description for " . substr(StringHelper::basename(get_class($this)), 0, -3) . " '{$this->name}'"];
         }
         $this->description = $docblock->getLongDescription()->getContents();
         $this->phpDocContext = $docblock->getContext();
         $this->tags = $docblock->getTags();
         foreach ($this->tags as $i => $tag) {
             if ($tag instanceof SinceTag) {
                 $this->since = $tag->getVersion();
                 unset($this->tags[$i]);
             } elseif ($tag instanceof DeprecatedTag) {
                 $this->deprecatedSince = $tag->getVersion();
                 $this->deprecatedReason = $tag->getDescription();
                 unset($this->tags[$i]);
             }
         }
     } elseif ($context !== null) {
         $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No docblock for element '{$this->name}'"];
     }
 }
Example #4
0
 public function __construct(\luya\web\Request $request, \luya\web\UrlManager $urlManager, array $config = [])
 {
     $this->request = $request;
     $this->urlManager = $urlManager;
     // parent object
     parent::__construct($config);
 }
Example #5
0
 /**
  * Fills property values
  * @param array $properties
  */
 public function __construct($properties)
 {
     foreach ($properties as $name => $value) {
         $this->hasProperty($name) && ($this->{$name} = $value);
     }
     parent::__construct();
 }
 /**
  *
  * @param array $config
  */
 public function __construct($config = [])
 {
     if (!empty($config['metadata']) && is_array($config['metadata'])) {
         $this->_metadata = $config['metadata'];
         unset($config['metadata']);
     }
     parent::__construct($config);
 }
 /**
  * @inheritdoc
  */
 public function __construct($config = [])
 {
     $source = ArrayHelper::remove($config, 'source');
     parent::__construct($config);
     if (!empty($source)) {
         $this->setSource($source);
     }
 }
Example #8
0
 /**
  * Конструктор
  * @param string $path
  * @param array $config
  * @throws \common\exceptions\IoException
  */
 public function __construct($path, $config = [])
 {
     if (!is_file($path)) {
         throw new IoException(Yii::t('core', 'File {file} does not exists.', ["{file}" => $path]));
     }
     $this->path = $path;
     parent::__construct($config);
 }
Example #9
0
 /**
  * @param string $name
  * @param string $alias
  * @param null|string $stamp
  * @param array $config
  */
 public function __construct($name, $alias, $stamp = null, $config = [])
 {
     $this->_name = $name;
     $this->_alias = $alias;
     $this->_stamp = $stamp;
     $this->_fileName = static::extractFileName($alias, $stamp);
     parent::__construct($config);
 }
 /**
  * @inheritdoc
  *adding rule that saying: not assigning id user to the view  
  *use global var $idAdmin
  */
 public function __construct($id, $user = null, $config = array())
 {
     if ($id != Yii::$app->params['idAdmin']) {
         $this->id = $id;
         $this->user = $user;
     }
     parent::__construct($config);
 }
Example #11
0
 /**
  * Constructor
  * @param \common\helper\DOMNode $node
  * @param array $config config array
  */
 public function __construct($config = [])
 {
     $this->reset();
     if (isset($config['DomNode'])) {
         $this->_root = $config['DomNode'];
         unset($config['DomNode']);
     }
     parent::__construct($config);
 }
 /**
  * @param string $callback
  * @param array $parameters
  * @param array $config
  */
 public function __construct($callback, array $parameters = [], $config = [])
 {
     $this->callback = $callback;
     $this->parameters = $parameters;
     Object::__construct($config);
     if (!is_string($this->callback) && !is_callable($this->callback)) {
         throw new InvalidParamException("Invalid scheduled callback event. Must be string or callable.");
     }
 }
 public function __construct($config = [])
 {
     $config = array_merge($this->defaults, $config);
     $this->variant = $config['variant'];
     $this->fileName = $config['fileName'];
     $this->PHPWord = new \PHPWord();
     $this->calculation = new Calculation();
     parent::__construct();
 }
Example #14
0
 public function __construct($config = [])
 {
     $config['config_file'] = \Yii::getAlias($config['config_file']);
     parent::__construct($config);
     if (!file_exists($this->config_file)) {
         $this->saveDefaultCfg();
     } else {
         $this->load($this->config_file);
     }
 }
 public function __construct($config)
 {
     parent::__construct($config);
     $this->tableNameRaw = Yii::$app->db->schema->getRawTableName($this->tableName);
     if (!$this->tableName) {
         throw new ErrorException("Table name not defined");
     }
     $this->afterInit();
     $this->generateFields();
 }
Example #16
0
 public function __construct($object, $config = array())
 {
     $this->object = $object;
     if ($object instanceof IKieFactSourceObject) {
         $this->factName = $object->getFactName();
         $this->identifier = $object->getIdentifier();
         $this->nodes = $object->getNodes();
     }
     parent::__construct($config);
 }
Example #17
0
 /**
  * AssignmentModel constructor.
  *
  * @param IdentityInterface $user
  * @param array $config
  *
  * @throws InvalidConfigException
  */
 public function __construct(IdentityInterface $user, $config = [])
 {
     $this->user = $user;
     $this->userId = $user->getId();
     $this->manager = Yii::$app->authManager;
     if ($this->userId === null) {
         throw new InvalidConfigException('The "userId" property must be set.');
     }
     parent::__construct($config);
 }
Example #18
0
 public function __construct($type, $name, $config = [])
 {
     parent::__construct($config);
     if (!$this->checkType($type)) {
         throw new Exception('wrong type');
     }
     if (!$this->checkName($name)) {
         throw new Exception('wrong name');
     }
     $this->_type = $type;
     $this->_name = $name;
 }
Example #19
0
 /**
  * Constructor.
  * @param string $path the file path that the new code should be saved to.
  * @param string $content the newly generated code content.
  * @param array $config name-value pairs that will be used to initialize the object properties
  */
 public function __construct($path, $content, $config = [])
 {
     parent::__construct($config);
     $this->path = strtr($path, '/\\', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
     $this->content = $content;
     $this->id = md5($this->path);
     if (is_file($path)) {
         $this->operation = file_get_contents($path) === $content ? self::OP_SKIP : self::OP_OVERWRITE;
     } else {
         $this->operation = self::OP_CREATE;
     }
 }
Example #20
0
 /**
  * @param string|object $source
  * @param array $config
  * @throws \yii\base\InvalidParamException
  * @internal param array $attributes
  */
 public function __construct($source, $config = [])
 {
     if (is_string($source)) {
         $this->_sourceClass = $source;
     } elseif (is_object($source)) {
         $this->_source = $source;
         $this->_sourceClass = get_class($source);
     } else {
         throw new InvalidParamException('$source must be an object or a class name.');
     }
     Object::__construct($config);
 }
Example #21
0
 public function __construct($providerId, $filename, $arrAccords)
 {
     $this->filename = $filename;
     $this->providerId = $providerId;
     $this->arrAccords = $arrAccords;
     foreach ($this->arrAccords as $k => $val) {
         if ("{$val}" == '0') {
             unset($this->arrAccords[$k]);
         }
     }
     $this->arrAccords = array_flip($this->arrAccords);
     return parent::__construct();
 }
Example #22
0
 public function __construct($app_secret = null, $app_token = null, $config = [])
 {
     parent::__construct($config);
     if (!$app_secret && !empty(Yii::$app->params['dropbox_secret'])) {
         $app_secret = Yii::$app->params['dropbox_secret'];
     }
     $this->app_secret = $app_secret;
     if (!$app_token && !empty(Yii::$app->params['dropbox_token'])) {
         $app_token = Yii::$app->params['dropbox_token'];
     }
     $this->app_token = $app_token;
     $this->_client = new dbx\Client($this->app_token, "PRO-Education/1.0", 'ru');
 }
 /**
  * Contruct an instance of the StatusIdConverter.
  * The parameter `map` must be defined in the configuration array passed as argument. It contains the 
  * associative array used to convert statuses.
  *
  * @param array $config
  * @throws InvalidConfigException
  */
 public function __construct($config = [])
 {
     if (!empty($config['map'])) {
         if (!is_array($config['map'])) {
             throw new InvalidConfigException('The map must be an array');
         }
         $this->_map = $config['map'];
         unset($config['map']);
     } else {
         throw new InvalidConfigException('missing map');
     }
     parent::__construct($config);
 }
 /**
  * Get repository from directory.
  * Throws RepositoryException if repository not found at dir.
  *
  * @param string $dir project path (not a path to .git or .hg!)
  * @param BaseWrapper $wrapper
  * @throws CommonException
  */
 public function __construct($dir, BaseWrapper $wrapper)
 {
     $projectPath = FileHelper::normalizePath(realpath($dir));
     $repositoryPath = FileHelper::normalizePath($projectPath . '/' . $wrapper->getRepositoryPathName());
     if (!is_dir($repositoryPath)) {
         throw new CommonException('Repository not found at ' . $dir);
     }
     $this->projectPath = $projectPath;
     $this->repositoryPath = $repositoryPath;
     $this->wrapper = $wrapper;
     $this->checkRepository();
     parent::__construct([]);
 }
Example #25
0
 /**
  * Constructor
  *
  * @param string $pathName
  * @param BaseRepository $repository
  * @param string|null $status file status in revision
  *
  * @throws CommonException
  */
 public function __construct($pathName, BaseRepository $repository, $status = null)
 {
     $this->name = basename($pathName);
     $this->path = FileHelper::normalizePath($pathName);
     // first character for status
     $this->status = !is_null($status) ? substr($status, 0, 1) : $status;
     $this->repository = $repository;
     if (!StringHelper::startsWith($this->path, $repository->getProjectPath())) {
         throw new CommonException("Path {$this->path} outband of repository");
     }
     $this->relativePath = substr($this->path, strlen($repository->getProjectPath()));
     parent::__construct([]);
 }
Example #26
0
 public function __construct()
 {
     parent::__construct();
     $allCategories = Category::find()->asArray()->all();
     //循环获取层次关系
     foreach ($allCategories as $v) {
         $this->_allCategories[$v['mid']] = $v;
         //将id作为key
         if (!array_key_exists($v['mid'], $this->_childCategoryIds)) {
             $this->_childCategoryIds[$v['mid']] = [];
         }
         $this->_childCategoryIds[$v['parent']][] = $v['mid'];
         $this->_parentCategoryIds[$v['mid']] = $v['parent'];
     }
 }
Example #27
0
 /**
  * Constructor.
  * @param Connection $conn connection interact with result
  * @param resource[]|resource $results result array of search in ldap directory
  * @param array $config name-value pairs that will be used to initialize the object properties
  */
 public function __construct(Connection $conn, $results, $config = [])
 {
     $this->_conn = $conn;
     $this->_results = $results;
     if (is_array($this->_results)) {
         foreach ($this->_results as $result) {
             $this->_count += $this->_conn->countEntries($result);
             $this->setEntries($result);
         }
     } else {
         $this->_count += $this->_conn->countEntries($this->_results);
         $this->setEntries($this->_results);
     }
     parent::__construct($config);
 }
 /**
  * Construct a workflow object.
  * @param array $config
  */
 public function __construct($config = [])
 {
     if (array_key_exists('metadata', $config) && is_array($config['metadata'])) {
         $this->_metadata = $config['metadata'];
         unset($config['metadata']);
     }
     if (array_key_exists('source', $config)) {
         $this->_source = $config['source'];
         if (!$this->_source instanceof IWorkflowSource) {
             throw new InvalidConfigException('The "source" property must implement interface raoul2000\\workflow\\source\\IWorkflowSource');
         }
         unset($config['source']);
     }
     parent::__construct($config);
 }
Example #29
0
 /**
  * @param \phpDocumentor\Reflection\FunctionReflector\ArgumentReflector $reflector
  * @param Context $context
  * @param array $config
  */
 public function __construct($reflector = null, $context = null, $config = [])
 {
     parent::__construct($config);
     if ($reflector === null) {
         return;
     }
     $this->name = $reflector->getName();
     $this->typeHint = $reflector->getType();
     $this->isOptional = $reflector->getDefault() !== null;
     // bypass $reflector->getDefault() for short array syntax
     if ($reflector->getNode()->default) {
         $this->defaultValue = PrettyPrinter::getRepresentationOfValue($reflector->getNode()->default);
     }
     $this->isPassedByReference = $reflector->isByRef();
 }
 /**
  * @param array $requestParams
  * @param array $config
  */
 public function __construct($requestParams = [], $config = [])
 {
     parent::__construct($config);
     $this->queryBuilder = \Yii::createObject(QueryBuilder::class, [null]);
     $this->locator = new ServiceLocator();
     $this->locator->setComponents($this->attributeHandlers());
     $query = $this->getQueryInstance();
     $query->query = new Bool();
     $query->filter = new \opus\elastic\elastica\filter\Bool();
     $query->limit = ArrayHelper::remove($requestParams, 'limit');
     $query->offset = ArrayHelper::remove($requestParams, 'offset');
     $query->orderBy = ArrayHelper::remove($requestParams, 'sort');
     $this->requestParams = $requestParams;
     $this->setAttributes();
 }