__construct() публичный Метод

Create a new collection.
public __construct ( mixed $items = [] ) : void
$items mixed
Результат void
Пример #1
0
 public function __construct(string $name, array $options = [])
 {
     parent::__construct();
     $this->name = $name;
     $this->caption = $options['caption'] ?? $name;
     $this->priority = $options['priority'] ?? $this->priority;
 }
Пример #2
0
 public function __construct($items = [])
 {
     $this->storagePath = storage_path('logs');
     $this->filesystem = new Filesystem(app('files'), $this->storagePath);
     parent::__construct($items);
     $this->load();
 }
Пример #3
0
 /**
  * Construct a collection of Result objects based on the hits
  * in the Elasticsearch response
  *
  * @param Response $response
  */
 public function __construct(Response $response)
 {
     $this->response = $response;
     parent::__construct(array_map(function ($hit) {
         return new Result($hit);
     }, $this->response->getHits()));
 }
Пример #4
0
 public function __construct(array $entities = null)
 {
     if ($entities) {
         $this->checkItemsAreMappable($entities);
     }
     parent::__construct($entities);
 }
Пример #5
0
 public function __construct($items = null)
 {
     if (is_null($items)) {
         return parent::__construct(config('amazon.mws'));
     }
     return parent::__construct($items);
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 public function __construct($items = null, $class_slug = null, $key_by = null)
 {
     $items = is_null($items) ? [] : $items;
     if ($items instanceof \Illuminate\Support\Collection) {
         return parent::__construct($items);
     }
     if ($class_slug) {
         $items = array_map(function ($item) use($class_slug) {
             if (is_null($item)) {
                 return $item;
             }
             if (!is_array($item)) {
                 throw new \Exception("Failed to cast a model");
             }
             $class = Model::getModelClass($class_slug);
             return new $class($item);
         }, $items);
     }
     if ($key_by) {
         $items = array_build($items, function ($key, $value) use($key_by) {
             /** @var Model $value */
             $key = $value instanceof Model ? $value->get($key_by) : data_get($value, $key_by);
             return [$key, $value];
         });
     }
     return parent::__construct($items);
 }
Пример #7
0
 /**
  * Create a new article collection instance.
  * 
  * @param  \JasonLewis\Website\Loader  $loader
  * @param  \Illuminate\Cache\CacheManager  $cache
  * @param  int  $expires
  * @param  array  $items
  * @return void
  */
 public function __construct(Loader $loader, CacheManager $cache, $expires, $items = [])
 {
     $this->loader = $loader;
     $this->cache = $cache;
     $this->expires = $expires;
     parent::__construct($items);
 }
 public function __construct(array $messages = [])
 {
     $messageModels = [];
     foreach ($messages as $message) {
         $messageModels[] = new Model($message);
     }
     parent::__construct($messageModels);
 }
Пример #9
0
 public function __construct($opt = [])
 {
     $opt = $this->convertOptions($opt);
     $options = $opt;
     $options['chart'] = new ChartPropertie(isset($options['chart']) ? $options['chart'] : []);
     parent::__construct($options);
     $this->resolveID($opt);
 }
 /**
  * @param array $params
  */
 public function __construct(array $params = array())
 {
     foreach ($params['profiles'] as &$profile) {
         $profile = new Subscription($profile);
     }
     parent::__construct($params['profiles']);
     unset($params);
 }
Пример #11
0
 /**
  * @param ServiceInterface[] $items
  */
 public function __construct($items = [])
 {
     $items = is_array($items) ? $items : $this->getArrayableItems($items);
     foreach ($items as $index => $item) {
         $this->checkValidService($item);
     }
     parent::__construct($items);
 }
 public function __construct(array $params = array())
 {
     $this->updatedAt = Carbon::createFromTimestamp($params['updatetime'], $params['timezone']);
     foreach ($params['measuregrps'] as &$group) {
         $group = new Measure($group);
     }
     parent::__construct($params['measuregrps']);
     unset($params);
 }
 /**
  * Create a new ContentItem.
  *
  *
  * @param array $items
  *
  * @throws MissingParameterContentItemException
  */
 public function __construct($items = [])
 {
     //New Up parent
     parent::__construct($items);
     //If we do not have content then throw an Exception
     if (!$this->has('content')) {
         throw new MissingParameterContentItemException('Personality Insights requires a content', 422);
     }
 }
Пример #14
0
 /**
  * Construct a collection of Eloquent models based on the search result
  *
  * @access public
  * @param Response $response
  */
 public function __construct(Response $response)
 {
     $this->response = $response;
     $ids = array_map(function ($hit) {
         return $hit['_id'];
     }, $this->response->getHits());
     $model = $response->getModel();
     parent::__construct($model::whereIn('id', $ids)->get()->toArray());
 }
Пример #15
0
 public function __construct($creds)
 {
     $this->connection = new PexConnection($creds);
     $accountlist = $this->connection->allAccounts();
     $items = array();
     foreach ($accountlist as $act) {
         $items[] = new Account($this->connection, $act);
     }
     parent::__construct($items);
 }
Пример #16
0
 /**
  * @param array|mixed $collection
  */
 function __construct($collection)
 {
     $this->original = $collection;
     $stack = [];
     $entity = $this->getEntityClass();
     foreach ($collection as $item) {
         $stack[] = new $entity($item);
     }
     parent::__construct($stack);
 }
 /**
  * Validates the provided array against the allowed classes property
  * and constructs the Collection object
  *
  * @param array $elements
  * @throws \Exception
  * @throws \InvalidArgumentException
  */
 public function __construct(array $elements = [])
 {
     $this->assertValidAllowedTypesAreSet();
     if ($this->shouldIgnoreInvalidElements()) {
         $elements = $this->getValidElements($elements);
     } else {
         $this->assertElementsAreValidTypes($elements);
     }
     parent::__construct($elements);
 }
Пример #18
0
 /**
  * Create a new theme collection.
  *
  * @param mixed $items
  */
 public function __construct($items = [])
 {
     $this->separateInvalidItems($items);
     parent::__construct($items);
     /* @var $theme Theme */
     foreach ($this->items as $theme) {
         if ($theme instanceof Theme) {
             $this->themeNames[] = $theme->getName();
         }
     }
 }
Пример #19
0
 public function __construct($withHeader = true, $fileName = false, $delimiter = false, $maxLength = false, $utf8 = false)
 {
     parent::__construct();
     $this->delimiter = $delimiter !== false ? $delimiter : $this->delimiter;
     $this->maxLength = $maxLength !== false ? $maxLength : $this->maxLength;
     $this->utf8 = $utf8;
     $this->files = new Filesystem();
     if ($fileName !== false) {
         $this->load($fileName, $withHeader);
     }
 }
 public function __construct($items = [])
 {
     if (!is_array($items) && !$items instanceof Traversable) {
         throw new InvalidArgumentException();
     }
     foreach ($items as $item) {
         if (!$item instanceof ExchangeRate) {
             throw new Exception('Only ExchangeRate objects can be added to a ExchangeRate collection.');
         }
     }
     parent::__construct($items);
 }
Пример #21
0
 /**
  * @param string $username
  */
 public function __construct($username)
 {
     parent::__construct();
     $this->items['username'] = $username;
     $this->items['hostKey'] = $this->generateHostKey($username);
     $this->items['version'] = null;
     $this->items['clientVersion'] = null;
     $this->items['path'] = storage_path(joinPaths('database', $username));
     if (!is_dir($this->getPath())) {
         mkdir($this->getPath(), 0777, true);
     }
 }
 public function __construct(array $params = array())
 {
     $items = array();
     if (isset($params['activities'])) {
         foreach ($params['activities'] as &$activity) {
             $activity = new Activity($activity);
         }
         $items = $params['activities'];
     } else {
         // We only have one item
         $items[] = $params;
     }
     parent::__construct($items);
     unset($params);
 }
Пример #23
0
 public function __construct($items = [], $directory = null, Filesystem $filesystem = null)
 {
     $this->filesystem = $filesystem === null ? new Filesystem() : $filesystem;
     if ($directory !== null) {
         // $items = collect($this->filesystem->files($directory))->map(function ($item) {
         //     return $this->parseFile($item);
         // })->sortByDesc(function ($item) {
         //     return $item['filectime'];
         // });
         $items = [];
         foreach ($this->filesystem->files($directory) as $file) {
             $items[] = $this->parseFile($file);
         }
         $this->directory = $directory;
     }
     parent::__construct($items);
 }
Пример #24
0
 /**
  * Create a new theme collection.
  *
  * @param mixed   $items
  * @param bool $themesFolder
  * @param array   $requiredFields
  * @param bool $exceptionOnInvalid
  */
 public function __construct($items = [], $themesFolder = false, array $requiredFields = [], $exceptionOnInvalid = false)
 {
     $this->requiredFields = $requiredFields;
     $this->exceptionOnInvalid = $exceptionOnInvalid;
     if (is_string($themesFolder)) {
         $themesFolder = realpath($themesFolder);
         $this->themesFolders[$themesFolder] = $themesFolder;
     }
     $this->separateInvalidItems($items);
     parent::__construct($items);
     /* @var $theme Theme */
     foreach ($this->items as $theme) {
         if ($theme instanceof Theme) {
             $this->themeNames[] = $theme->getName();
         }
     }
 }
Пример #25
0
 /**
  * Create a new values collection.
  *
  * @param mixed $items
  */
 public function __construct(Factory $factory, Property $property, $items = [])
 {
     $this->property = $property;
     $this->factory = $factory;
     parent::__construct($items);
 }
Пример #26
0
 /**
  * @param array|mixed $item
  */
 public function __construct($item)
 {
     parent::__construct($item);
 }
Пример #27
0
 public function __construct($data = [])
 {
     parent::__construct($data);
     $this->resolveData();
 }
Пример #28
0
 public function __construct(array $items)
 {
     parent::__construct($items);
 }
Пример #29
0
 public function __construct(array $data, Database $database)
 {
     $this->database = $database;
     parent::__construct($data);
 }
Пример #30
0
 public function __construct()
 {
     parent::__construct([new Overall(), new Attack(), new Defence(), new Strength(), new Constitution(), new Ranged(), new Prayer(), new Magic(), new Cooking(), new Woodcutting(), new Fletching(), new Fishing(), new Firemaking(), new Crafting(), new Smithing(), new Mining(), new Herblore(), new Agility(), new Thieving(), new Slayer(), new Farming(), new Runecrafting(), new Hunter(), new Construction(), new Summoning(), new Dungeoneering(), new Divination(), new Invention()]);
 }