当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::create方法代码示例

本文整理汇总了PHP中Collection::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::create方法的具体用法?PHP Collection::create怎么用?PHP Collection::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collection的用法示例。


在下文中一共展示了Collection::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAvailableConfigOptions

 /**
  * Return a list of available configuration options.
  *
  * @param Collection $availableTypes Collection of Injector\InjectorInterface::TYPE_*
  *     constants indicating valid package types that could be injected.
  * @param string $projectRoot Path to the project root; assumes PWD by
  *     default.
  * @return Collection Collection of ConfigOption instances.
  */
 public function getAvailableConfigOptions(Collection $availableTypes, $projectRoot = '')
 {
     // Create an initial collection to which we'll append.
     // This approach is used to ensure indexes are sane.
     $discovered = new Collection([new ConfigOption('Do not inject', new Injector\NoopInjector())]);
     Collection::create($this->discovery)->map(function ($discoveryClass) use($projectRoot) {
         if (is_array($discoveryClass)) {
             return new ConfigDiscovery\DiscoveryChain($discoveryClass, $projectRoot);
         }
         return new $discoveryClass($projectRoot);
     })->filter(function ($discovery) {
         return $discovery->locate();
     })->map(function ($discovery, $file) use($projectRoot, $availableTypes) {
         // Look up the injector based on the file type
         $injectorClass = $this->injectors[$file];
         if (is_array($injectorClass)) {
             return new Injector\ConfigInjectorChain($injectorClass, $discovery, $availableTypes, $projectRoot);
         }
         return new $injectorClass($projectRoot);
     })->filter(function ($injector) use($availableTypes) {
         return $availableTypes->reduce(function ($flag, $type) use($injector) {
             return $flag || $injector->registersType($type);
         }, false);
     })->each(function ($injector, $file) use($discovered) {
         $discovered[] = new ConfigOption($file, $injector);
     });
     return 1 === $discovered->count() ? new Collection([]) : $discovered;
 }
开发者ID:zendframework,项目名称:zend-component-installer,代码行数:37,代码来源:ConfigDiscovery.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $rules = ['name' => 'required|min:2', 'color' => 'required|max:7|min:3', 'is_public' => 'required'];
     $validator = \Validator::make(Input::only('name', 'color', 'is_public'), $rules);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator);
     }
     $collection = Collection::create(['name' => Input::get('name'), 'color' => Input::get('color'), 'is_public' => Input::get('is_public')]);
     $user = Auth::User();
     $user->collections()->save($collection);
     Flash::success('Collection created!');
     return redirect()->route('collections.show', $collection->id);
 }
开发者ID:ecwilson123,项目名称:simplenote,代码行数:19,代码来源:CollectionsController.php

示例3: Event_handler

function Event_handler($handler)
{
    if (is_object($handler)) {
        return array('type' => 'object', 'object' => $handler, 'event_handler' => true);
    } elseif (is_string($handler) && class_exists($handler)) {
        return array('type' => 'class', 'class' => $handler, 'event_handler' => true);
    } else {
        if (is_array($handler)) {
            return array('type' => 'bootable', 'boot' => \Collection::create($handler), 'event_handler' => true);
        } else {
            return array('type' => 'bootable', 'boot' => \Executor::create($handler), 'event_handler' => true);
        }
    }
}
开发者ID:silversthem,项目名称:simPHPle,代码行数:14,代码来源:controller.php

示例4: __construct

 /**
  * 
  * @param CollectionEnumeratorInterface[] $eachCollectionEnumerator
  */
 public function __construct($eachCollectionEnumerator)
 {
     $this->collectionEnumeratorArray = Collection::create($eachCollectionEnumerator)->getArray();
 }
开发者ID:northborndesign,项目名称:northborndesign.tundra.collections,代码行数:8,代码来源:CompositeCollectionEnumerator.php

示例5: __construct

 /**
  *  Constructor
  */
 public function __construct()
 {
     $this->extensions = Collection::create();
 }
开发者ID:mecum,项目名称:expand,代码行数:7,代码来源:Manager.php


注:本文中的Collection::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。