/**
  * 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;
 }
 /**
  * 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);
 }
Example #3
0
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);
        }
    }
}
 /**
  * 
  * @param CollectionEnumeratorInterface[] $eachCollectionEnumerator
  */
 public function __construct($eachCollectionEnumerator)
 {
     $this->collectionEnumeratorArray = Collection::create($eachCollectionEnumerator)->getArray();
 }
Example #5
0
 /**
  *  Constructor
  */
 public function __construct()
 {
     $this->extensions = Collection::create();
 }