Collection PHP Class Code Examples

This page contains top rated real world PHP examples of class Collection extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: RestResponse.php Project: cvele/fondacija
0
 public function createResponseArray($data, $entity, Request $request)
 {
     $this->request = $request;
     $fractal = new Manager();
     $fractal->parseIncludes($request->query->get('include', []));
     $fractal->setSerializer(new ArraySerializer());
     $transformer = $this->transformerFactory->get($entity);
     if ($data instanceof Pagerfanta) {
         $pager = $data;
         $pager->setMaxPerPage($request->query->get('limit', 10));
         $pager->setCurrentPage($request->query->get('page', 1));
         $results = $pager->getCurrentPageResults();
         $resource = new Collection($results, $transformer);
         $resource->setPaginator(new PagerfantaPaginatorAdapter($pager, [$this, 'paginationRouter']));
     } elseif ($data instanceof DoctrineQuery) {
         $ormAdapter = new DoctrineORMAdapter($data);
         $pager = new Pagerfanta($ormAdapter);
         $pager->setMaxPerPage($request->query->get('limit', 10));
         $pager->setCurrentPage($request->query->get('page', 1));
         $results = $pager->getCurrentPageResults();
         $resource = new Collection($results, $transformer);
         $resource->setPaginator(new PagerfantaPaginatorAdapter($pager, [$this, 'paginationRouter']));
     } elseif (is_array($data)) {
         $resource = new Collection($data, $transformer);
     } else {
         $resource = new Item($data, $transformer);
     }
     $data = $fractal->createData($resource)->toArray();
     return $data;
 }
Example #2
Show file File: OcInformation.php Project: jkhaled/OpenCartDoctrineSchema
0
 public function __construct(Doctrine\Common\Collections\Collection $store, Doctrine\Common\Collections\Collection $language, $bottom, $sortOrder, $status)
 {
     $this->store = $store;
     $this->language = $language;
     $this->bottom = $bottom;
     $this->sortOrder = $sortOrder;
     $this->status = $status;
 }
Example #3
Show file File: ToMany.php Project: vigm/advancedMD
0
 public function fill($related, $_skip_inverse = FALSE)
 {
     if (is_array($related)) {
         $related = new Collection($related);
     }
     if ($related instanceof Model) {
         $related = new Collection(array($related));
     }
     if ($related instanceof Collection) {
         $this->ensureAssociation($related);
     }
     return parent::fill($related, $_skip_inverse);
 }
Example #4
Show file File: XmlGenerator.php Project: younginnovations/aidstream
0
 /**
  * @param Activity   $activity
  * @param Collection $transaction
  * @param Collection $result
  * @param Settings   $settings
  * @param            $activityElement
  * @param            $orgElem
  * @param            $organization
  */
 public function generateActivityXml(Activity $activity, Collection $transaction, Collection $result, Settings $settings, $activityElement, $orgElem, $organization)
 {
     $this->settings = $settings;
     $publisherId = $this->settings->registry_info[0]['publisher_id'];
     $filename = sprintf('%s-%s.xml', $publisherId, $settings->publishing_type == "segmented" ? $this->segmentedXmlFile($activity) : 'activities');
     $publishedActivity = sprintf('%s-%s.xml', $publisherId, $activity->id);
     $xml = $this->getXml($activity, $transaction, $result, $settings, $activityElement, $orgElem, $organization);
     $result = Storage::put(sprintf('%s%s', config('filesystems.xml'), $publishedActivity), $xml->saveXML());
     if ($result) {
         $publishedFiles = $settings->publishing_type != "segmented" ? $this->savePublishedFiles($filename, $activity->organization_id, $publishedActivity) : $this->saveSegmentedPublishedFiles($filename, $activity, $publishedActivity);
         $this->getMergeXml($publishedFiles, $filename);
     }
 }
Example #5
Show file File: OcCustomField.php Project: jkhaled/OpenCartDoctrineSchema
0
 public function __construct(Doctrine\Common\Collections\Collection $language, Doctrine\Common\Collections\Collection $customerGroup, $type, $value, $location, $status, $sortOrder)
 {
     $this->language = $language;
     $this->customerGroup = $customerGroup;
     $this->type = $type;
     $this->value = $value;
     $this->location = $location;
     $this->status = $status;
     $this->sortOrder = $sortOrder;
 }
Example #6
Show file File: OcStore.php Project: jkhaled/OpenCartDoctrineSchema
0
 public function __construct(Doctrine\Common\Collections\Collection $product, Doctrine\Common\Collections\Collection $manufacturer, Doctrine\Common\Collections\Collection $information, Doctrine\Common\Collections\Collection $category, $name, $url, $ssl)
 {
     $this->product = $product;
     $this->manufacturer = $manufacturer;
     $this->information = $information;
     $this->category = $category;
     $this->name = $name;
     $this->url = $url;
     $this->ssl = $ssl;
 }
Example #7
Show file File: CDiscountAPI.php Project: Assassinsscript/CrisisCenter
0
 public function getCollectionFromCart($cart)
 {
     $collection = new Collection();
     if ($cart->ProductCount == 1) {
         $collection = new Collection([$cart->Items->CartLine]);
     } elseif ($cart->ProductCount > 1) {
         $collection = new Collection($cart->Items->CartLine);
     }
     return $collection->keyBy('ProductId');
 }
Example #8
Show file File: Clasificacion.php Project: villapilla/PHP
0
 public static function generateClasificacion($liga)
 {
     $jornadasAll = $liga->getJornadas();
     $jornadas = new Collection();
     $jornadaActual = $jornadasAll->iterate();
     while ($jornadaActual) {
         if ($jornadaActual->getEstado() === "true") {
             $jornadas->add($jornadaActual);
         }
         $jornadaActual = $jornadasAll->iterate();
     }
     $equipos = new Collection();
     $jornadaActual = $jornadas->iterate();
     while ($jornadaActual) {
         $partidos = $jornadaActual->getPartidos();
         $partidoActual = $partidos->iterate();
         if ($equipos->isEmpty()) {
             $partidos->resetIterator();
             $partidoActual = $partidos->iterate();
             while ($partidoActual) {
                 $equipoLocal = new Equipo($partidoActual->getEqLocal()->getNombre(), $partidoActual->getEqLocal()->getId_equipo(), 0, 0, 0, 0);
                 $equipoVisitante = new Equipo($partidoActual->getEqVisitante()->getNombre(), $partidoActual->getEqVisitante()->getId_equipo(), 0, 0, 0, 0);
                 $equipos->add($equipoLocal);
                 $equipos->add($equipoVisitante);
                 $partidoActual = $partidos->iterate();
             }
             $partidos->resetIterator();
             $partidoActual = $partidos->iterate();
         }
         while ($partidoActual) {
             $equipoLocal = $equipos->getByProperty("id_equipo", $partidoActual->getEqLocal()->getId_equipo());
             $equipoVisitante = $equipos->getByProperty("id_equipo", $partidoActual->getEqVisitante()->getId_equipo());
             $golesL = $partidoActual->getGolesLocal();
             $golesV = $partidoActual->getGolesVisitante();
             if ($golesL > $golesV) {
                 $equipoLocal->setPuntos($equipoLocal->getPuntos() + 3);
             } else {
                 if ($golesL < $golesV) {
                     $equipoVisitante->setPuntos($equipoVisitante->getPuntos() + 3);
                 } else {
                     $equipoLocal->setPuntos($equipoLocal->getPuntos() + 1);
                     $equipoVisitante->setPuntos($equipoVisitante->getPuntos() + 1);
                 }
             }
             $equipoLocal->setGolesF($equipoLocal->getGolesF() + $golesL);
             $equipoLocal->setGolesC($equipoLocal->getGolesC() + $golesV);
             $equipoVisitante->setGolesF($equipoVisitante->getGolesF() + $golesV);
             $equipoVisitante->setGolesC($equipoVisitante->getGolesC() + $golesL);
             $equipoLocal->setDifG();
             $equipoVisitante->setDifG();
             $partidoActual = $partidos->iterate();
         }
         $jornadaActual = $jornadas->iterate();
     }
     return $equipos;
 }
Example #9
Show file File: CollectionTest.php Project: EnmanuelCode/backend-laravel
0
 /**
  * @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
  * 
  * @return void
  */
 public function testConstructWithNamespace()
 {
     $collection = new Collection(array(), new Context('\\My\\Space'));
     $this->assertEquals('My\\Space', $collection->getContext()->getNamespace());
     $collection = new Collection(array(), new Context('My\\Space'));
     $this->assertEquals('My\\Space', $collection->getContext()->getNamespace());
     $collection = new Collection(array(), null);
     $this->assertEquals('', $collection->getContext()->getNamespace());
 }
Example #10
Show file File: MediaRepositoryTest.php Project: Silwereth/sulu
0
 protected function setUpCollection()
 {
     $collection = new Collection();
     $style = ['type' => 'circle', 'color' => '#ffcc00'];
     $collection->setStyle(json_encode($style));
     // Create Collection Type
     $collectionType = new CollectionType();
     $collectionType->setName('Default Collection Type');
     $collectionType->setDescription('Default Collection Type');
     $collection->setType($collectionType);
     // Collection Meta 1
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle('Test Collection');
     $collectionMeta->setDescription('This Description is only for testing');
     $collectionMeta->setLocale('en-gb');
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     // Collection Meta 2
     $collectionMeta2 = new CollectionMeta();
     $collectionMeta2->setTitle('Test Kollektion');
     $collectionMeta2->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta2->setLocale('de');
     $collectionMeta2->setCollection($collection);
     $collection->addMeta($collectionMeta2);
     $this->em->persist($collection);
     $this->em->persist($collectionType);
     $this->em->persist($collectionMeta);
     $this->em->persist($collectionMeta2);
     $this->collections[] = $collection;
     $collection = new Collection();
     $style = ['type' => 'circle', 'color' => '#ffcc00'];
     $collection->setStyle(json_encode($style));
     // Create Collection Type
     $collectionType = new CollectionType();
     $collectionType->setName('Default Collection Type');
     $collectionType->setDescription('Default Collection Type');
     $collection->setType($collectionType);
     // Collection Meta 1
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle('Test Collection');
     $collectionMeta->setDescription('This Description is only for testing');
     $collectionMeta->setLocale('en-gb');
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     // Collection Meta 2
     $collectionMeta2 = new CollectionMeta();
     $collectionMeta2->setTitle('Test Kollektion');
     $collectionMeta2->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta2->setLocale('de');
     $collectionMeta2->setCollection($collection);
     $collection->addMeta($collectionMeta2);
     $this->em->persist($collection);
     $this->em->persist($collectionType);
     $this->em->persist($collectionMeta);
     $this->em->persist($collectionMeta2);
     $this->collections[] = $collection;
 }
Example #11
Show file File: OcDownload.php Project: jkhaled/OpenCartDoctrineSchema
0
 public function __construct(Doctrine\Common\Collections\Collection $product, Doctrine\Common\Collections\Collection $language, $filename, $mask, DateTime $dateAdded)
 {
     $this->product = $product;
     $this->language = $language;
     $this->filename = $filename;
     $this->mask = $mask;
     $this->dateAdded = $dateAdded;
 }
Example #12
Show file File: FractalServiceProvider.php Project: sonoftheweb/laravel-angular-cms
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $request = $this->app->make('request');
     $fractal = $this->app->make('League\\Fractal\\Manager');
     $fractal = $fractal->setSerializer(new CustomArraySerializer());
     if ($request->has('include')) {
         $fractal->parseIncludes($request->get('include'));
     }
     $result = ['status' => true];
     response()->macro('return', function ($array = [], array $headers = []) use($result) {
         $result = array_merge($result, $array);
         return response()->json(['result' => $result], 200, $headers);
     });
     response()->macro('item', function ($item, \League\Fractal\TransformerAbstract $transformer, $status = 200, array $headers = []) use($fractal, $result) {
         $resource = new \League\Fractal\Resource\Item($item, $transformer, null);
         $result['result'] = $fractal->createData($resource)->toArray();
         return response()->json($result, $status, $headers);
     });
     response()->macro('collection', function ($collection, \League\Fractal\TransformerAbstract $transformer, $status = 200, array $headers = []) use($fractal, $result) {
         $resource = new \League\Fractal\Resource\Collection($collection, $transformer, null);
         $result['result'] = $fractal->createData($resource)->toArray();
         return response()->json($result, $status, $headers);
     });
     response()->macro('paginator', function ($collection, \League\Fractal\TransformerAbstract $transformer, $status = 200, array $headers = []) use($fractal, $result) {
         $resource = new \League\Fractal\Resource\Collection($collection, $transformer, null);
         $resource->setPaginator(new IlluminateSimplePaginatorAdapter($collection));
         $result['result'] = $fractal->createData($resource)->toArray();
         $result['meta'] = $result['result']['meta'];
         unset($result['result']['meta']);
         return response()->json($result, $status, $headers);
     });
 }
Example #13
Show file File: OcCustomerGroup.php Project: jkhaled/OpenCartDoctrineSchema
0
 public function __construct(Doctrine\Common\Collections\Collection $taxRate, Doctrine\Common\Collections\Collection $language, Doctrine\Common\Collections\Collection $customField, $approval, $sortOrder)
 {
     $this->taxRate = $taxRate;
     $this->language = $language;
     $this->customField = $customField;
     $this->approval = $approval;
     $this->sortOrder = $sortOrder;
 }
Example #14
Show file File: ElementApiController.php Project: jonleesmith/jonleesmith
0
 /**
  * Returns the requested elements as JSON
  *
  * @param callable|null $configFactory A function for generating the config
  * @param array|null    $config        The API endpoint configuration
  *
  * @throws Exception
  * @throws HttpException
  */
 public function actionGetElements($configFactory = null, array $config = null)
 {
     if ($configFactory !== null) {
         $params = craft()->urlManager->getRouteParams();
         $variables = isset($params['variables']) ? $params['variables'] : null;
         $config = $this->_callWithParams($configFactory, $variables);
     }
     // Merge in default config options
     $config = array_merge(['paginate' => true, 'pageParam' => 'page', 'elementsPerPage' => 100, 'first' => false, 'transformer' => 'Craft\\ElementApi_ElementTransformer'], craft()->config->get('defaults', 'elementapi'), $config);
     if ($config['pageParam'] == 'p') {
         throw new Exception('The pageParam setting cannot be set to "p" because that’s the parameter Craft uses to check the requested path.');
     }
     if (!isset($config['elementType'])) {
         throw new Exception('Element API configs must specify the elementType.');
     }
     /** @var ElementCriteriaModel $criteria */
     $criteria = craft()->elements->getCriteria($config['elementType'], ['limit' => null]);
     if (!empty($config['criteria'])) {
         $criteria->setAttributes($config['criteria']);
     }
     // Load Fractal
     $pluginPath = craft()->path->getPluginsPath() . 'elementapi/';
     require $pluginPath . 'vendor/autoload.php';
     $fractal = new Manager();
     $fractal->setSerializer(new ArraySerializer());
     // Define the transformer
     if (is_callable($config['transformer']) || $config['transformer'] instanceof TransformerAbstract) {
         $transformer = $config['transformer'];
     } else {
         Craft::import('plugins.elementapi.ElementApi_ElementTransformer');
         $transformer = Craft::createComponent($config['transformer']);
     }
     if ($config['first']) {
         $element = $criteria->first();
         if (!$element) {
             throw new HttpException(404);
         }
         $resource = new Item($element, $transformer);
     } else {
         if ($config['paginate']) {
             // Create the paginator
             require $pluginPath . 'ElementApi_PaginatorAdapter.php';
             $paginator = new ElementApi_PaginatorAdapter($config['elementsPerPage'], $criteria->total(), $config['pageParam']);
             // Fetch this page's elements
             $criteria->offset = $config['elementsPerPage'] * ($paginator->getCurrentPage() - 1);
             $criteria->limit = $config['elementsPerPage'];
             $elements = $criteria->find();
             $paginator->setCount(count($elements));
             $resource = new Collection($elements, $transformer);
             $resource->setPaginator($paginator);
         } else {
             $resource = new Collection($criteria, $transformer);
         }
     }
     JsonHelper::sendJsonHeaders();
     echo $fractal->createData($resource)->toJson();
     // End the request
     craft()->end();
 }
Example #15
Show file File: ManagerController.php Project: FinBoWa/silverstripe-cacheinclude-manager
0
 /**
  * @param \SS_HTTPRequest $request
  * @return \SS_HTTPResponse
  */
 protected function cacheGET(SS_HTTPRequest $request)
 {
     $statusCode = 200;
     $name = $request->param('ID');
     $key = $request->param('OtherID');
     $cacheTransformer = new Transformers\CacheTransformer();
     $this->response->addHeader('Content-Type', 'application/json');
     if ($name) {
         try {
             if ($key) {
                 $resource = new Item($this->cacheModel->getByKey($name, $key), $cacheTransformer);
             } else {
                 $resource = new Collection($this->cacheModel->get($name), $cacheTransformer);
             }
         } catch (\InvalidArgumentException $e) {
             $statusCode = 400;
             $resource = $this->getSuccessResource(false);
         }
     } else {
         $resource = new Collection($this->cacheModel->getAll(), $cacheTransformer);
     }
     $this->response->setStatusCode($statusCode);
     $this->response->setBody($this->resourceToJson($resource));
     return $this->response;
 }
Example #16
Show file File: AdminGamificationController.php Project: dev-lav/htdocs
0
 public function renderView()
 {
     $badges_feature = new Collection('badge', $this->context->language->id);
     $badges_feature->where('type', '=', 'feature');
     $badges_feature->orderBy('id_group');
     $badges_feature->orderBy('group_position');
     $badges_achievement = new Collection('badge', $this->context->language->id);
     $badges_achievement->where('type', '=', 'achievement');
     $badges_achievement->orderBy('id_group');
     $badges_achievement->orderBy('group_position');
     $badges_international = new Collection('badge', $this->context->language->id);
     $badges_international->where('type', '=', 'international');
     $badges_international->orderBy('id_group');
     $badges_international->orderBy('group_position');
     $groups = array();
     $query = new DbQuery();
     $query->select('DISTINCT(b.`id_group`), bl.group_name, b.type');
     $query->from('badge', 'b');
     $query->join('
LEFT JOIN `' . _DB_PREFIX_ . 'badge_lang` bl ON bl.`id_badge` = b.`id_badge`');
     $query->where('bl.id_lang = ' . (int) $this->context->language->id);
     $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
     foreach ($result as $res) {
         $groups['badges_' . $res['type']][$res['id_group']] = $res['group_name'];
     }
     $badges_type = array('badges_feature' => array('name' => $this->l('Features'), 'badges' => $badges_feature), 'badges_achievement' => array('name' => $this->l('Achievements'), 'badges' => $badges_achievement), 'badges_international' => array('name' => $this->l('International'), 'badges' => $badges_international));
     $levels = array(1 => $this->l('1. Beginner'), 2 => $this->l('2. Pro'), 3 => $this->l('3. Expert'), 4 => $this->l('4. Wizard'), 5 => $this->l('5. Guru'), 6 => $this->l('6. Legend'));
     $this->tpl_view_vars = array('badges_type' => $badges_type, 'current_level_percent' => (int) Configuration::get('GF_CURRENT_LEVEL_PERCENT'), 'current_level' => (int) Configuration::get('GF_CURRENT_LEVEL'), 'groups' => $groups, 'levels' => $levels);
     if (version_compare(_PS_VERSION_, '1.5.6.0', '>')) {
         $this->base_tpl_view = 'view_bt.tpl';
     }
     return parent::renderView();
 }
Example #17
Show file File: MainController.php Project: Symfomany/laravelcinema
0
 /**
  * Page Dashboard.
  */
 public function dashboard()
 {
     $nbacteurs = Actors::count();
     $nbcommentaires = Comments::count();
     $nbmovies = Movies::count();
     $nbseances = Sessions::count();
     $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
     $collection = new \MongoDB\Collection($manager, 'laravel', 'videos');
     $videos = collect($collection->find()->toArray())->shuffle();
     $collection = new \MongoDB\Collection($manager, 'laravel', 'stats');
     $youtubeinfo = collect($collection->find(['origin' => 'Youtube'])->toArray())->first();
     $collection = new \MongoDB\Collection($manager, 'laravel', 'stats');
     $tweeterinfo = collect($collection->find(['origin' => 'Twitter', 'type' => 'infos'])->toArray())->first();
     $actor = new Actors();
     // Je récpere mon modèle
     $comment = new Comments();
     // Je récpere mon modèle
     $movie = new Movies();
     // Je récpere mon modèle
     $session = new Sessions();
     // Je récpere mon modèle
     $user = new User();
     // Je récpere mon modèle
     $avgacteurs = $actor->getAvgActors();
     $avgnotecommentaire = $comment->getAvgNote();
     $avgnotepresse = $movie->getAvgNotePresse();
     $avghour = $session->getAvgHourDate();
     $seances = $session->getNextSession();
     $users = $user->getLastUsers();
     return view('Main/dashboard', ['avgnotecommentaire' => $avgnotecommentaire->avgnote, 'avgnotepresse' => $avgnotepresse->avgpress, 'avgacteurs' => $avgacteurs->age, 'videos' => $videos, 'video' => $videos[0], 'youtubeinfo' => $youtubeinfo->data, 'tweeterinfo' => $tweeterinfo['data'][0], 'youtubeinfodateupdated' => $youtubeinfo->created, 'tweeterinfodateupdated' => $tweeterinfo['created_at'], 'avghour' => $avghour->avghour, 'nbacteurs' => $nbacteurs, 'nbcommentaires' => $nbcommentaires, 'nbmovies' => $nbmovies, 'nbseances' => $nbseances, 'seances' => $seances, 'users' => $users]);
 }
Example #18
Show file File: BaseEngine.php Project: thesaputra/xyz-prx
0
 /**
  * Render json response.
  *
  * @param bool $object
  * @return \Illuminate\Http\JsonResponse
  */
 public function render($object = false)
 {
     $output = ['draw' => (int) $this->request['draw'], 'recordsTotal' => $this->totalRecords, 'recordsFiltered' => $this->filteredRecords];
     if (isset($this->transformer)) {
         $fractal = new Manager();
         if ($this->request->get('include')) {
             $fractal->parseIncludes($this->request->get('include'));
         }
         $serializer = $this->serializer ?: Config::get('datatables.fractal.serializer', 'League\\Fractal\\Serializer\\DataArraySerializer');
         $fractal->setSerializer(new $serializer());
         //Get transformer reflection
         //Firs method parameter should be data/object to transform
         $reflection = new \ReflectionMethod($this->transformer, 'transform');
         $parameter = $reflection->getParameters()[0];
         //If parameter is class assuming it requires object
         //Else just pass array by default
         if ($parameter->getClass()) {
             $resource = new Collection($this->results(), new $this->transformer());
         } else {
             $resource = new Collection($this->getProcessedData($object), new $this->transformer());
         }
         $collection = $fractal->createData($resource)->toArray();
         $output['data'] = $collection['data'];
     } else {
         $output['data'] = Helper::transform($this->getProcessedData($object));
     }
     if ($this->isDebugging()) {
         $output = $this->showDebugger($output);
     }
     return new JsonResponse($output);
 }
Example #19
Show file File: Youtube.php Project: Symfomany/laravelcinema
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $keyword = $this->argument('keyword');
     $channel = Yt::getChannelByName('allocine');
     if (!empty($channel)) {
         $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
         $collection = new \MongoDB\Collection($manager, 'laravel.stats');
         $collection->deleteMany([]);
         $collection = new \MongoDB\Collection($manager, 'laravel.stats');
         $stat = ['origin' => 'Youtube', 'type' => 'search', 'data' => $channel, 'created' => new \MongoDB\BSON\UTCDatetime(time())];
         $collection->insertOne($stat);
     }
     $params = ['q' => $keyword, 'type' => 'video', 'part' => 'id, snippet', 'maxResults' => 30];
     $videos = Yt::searchAdvanced($params, true)['results'];
     if (!empty($videos)) {
         $collection = new \MongoDB\Collection($manager, 'laravel.videos');
         $collection->deleteMany([]);
         foreach ($videos as $video) {
             $collection = new \MongoDB\Collection($manager, 'laravel.videos');
             $stat = ['data' => $video, 'created' => new \MongoDB\BSON\UTCDatetime(time())];
             $collection->insertOne($stat);
         }
     }
     Log::info("Import de l'API Youtube video done! ");
 }
Example #20
Show file File: CodiceFiscaleControllerProvider.php Project: DavidePastore/codice-fiscale-rest
0
 public function connect(Application $app)
 {
     $api = $app['controllers_factory'];
     //Calculate the codice fiscale by the given parameters.
     $api->get('/calculate', function (Application $app, Request $request) {
         $constraint = new Assert\Collection(array('name' => $app['codice-fiscale-rest.constraints']['name'], 'surname' => $app['codice-fiscale-rest.constraints']['surname'], 'gender' => $app['codice-fiscale-rest.constraints']['gender'], 'birthDate' => $app['codice-fiscale-rest.constraints']['birthDate'], 'belfioreCode' => $app['codice-fiscale-rest.constraints']['belfioreCode'], 'omocodiaLevel' => $app['codice-fiscale-rest.constraints']['omocodiaLevel']));
         $data = array('name' => $request->get('name', ''), 'surname' => $request->get('surname', ''), 'gender' => $request->get('gender', ''), 'birthDate' => $request->get('birthDate', ''), 'belfioreCode' => $request->get('belfioreCode', ''), 'omocodiaLevel' => $request->get('omocodiaLevel', 0));
         $errors = $app['validator']->validate($data, $constraint);
         $response = new \stdClass();
         if (count($errors) > 0) {
             $response = $this->generateResponseFromErrors($errors);
         } else {
             $subject = new Subject($data);
             $calculator = new Calculator($subject, array('omocodiaLevel' => $data['omocodiaLevel']));
             $codiceFiscale = $calculator->calculate();
             $response->status = true;
             $response->codiceFiscale = $codiceFiscale;
         }
         return new JsonResponse($response);
     })->bind('apiCalculate');
     //Calculate all the codice fiscale by the given parameters.
     $api->get('/calculateAll', function (Application $app, Request $request) {
         $constraint = new Assert\Collection(array('name' => $app['codice-fiscale-rest.constraints']['name'], 'surname' => $app['codice-fiscale-rest.constraints']['surname'], 'gender' => $app['codice-fiscale-rest.constraints']['gender'], 'birthDate' => $app['codice-fiscale-rest.constraints']['birthDate'], 'belfioreCode' => $app['codice-fiscale-rest.constraints']['belfioreCode']));
         $data = array('name' => $request->get('name', ''), 'surname' => $request->get('surname', ''), 'gender' => $request->get('gender', ''), 'birthDate' => $request->get('birthDate', ''), 'belfioreCode' => $request->get('belfioreCode', ''));
         $errors = $app['validator']->validate($data, $constraint);
         $response = new \stdClass();
         if (count($errors) > 0) {
             $response = $this->generateResponseFromErrors($errors);
         } else {
             $subject = new Subject($data);
             $calculator = new Calculator($subject);
             $codiciFiscali = $calculator->calculateAllPossibilities();
             $response->status = true;
             $response->codiciFiscali = $codiciFiscali;
         }
         return new JsonResponse($response);
     })->bind('apiCalculateAll');
     //Check if the given parameters are ok for the given parameters.
     $api->get('/check', function (Application $app, Request $request) {
         $constraint = new Assert\Collection(array('name' => $app['codice-fiscale-rest.constraints']['name'], 'surname' => $app['codice-fiscale-rest.constraints']['surname'], 'gender' => $app['codice-fiscale-rest.constraints']['gender'], 'birthDate' => $app['codice-fiscale-rest.constraints']['birthDate'], 'belfioreCode' => $app['codice-fiscale-rest.constraints']['belfioreCode'], 'codiceFiscale' => $app['codice-fiscale-rest.constraints']['codiceFiscale'], 'omocodiaLevel' => $app['codice-fiscale-rest.constraints']['omocodiaLevel']));
         $data = array('name' => $request->get('name', ''), 'surname' => $request->get('surname', ''), 'gender' => $request->get('gender', ''), 'birthDate' => $request->get('birthDate', ''), 'belfioreCode' => $request->get('belfioreCode', ''), 'codiceFiscale' => $request->get('codiceFiscale', ''), 'omocodiaLevel' => $request->get('omocodiaLevel', Checker::ALL_OMOCODIA_LEVELS));
         $errors = $app['validator']->validate($data, $constraint);
         $response = new \stdClass();
         if (count($errors) > 0) {
             $response = $this->generateResponseFromErrors($errors);
         } else {
             $subject = new Subject($data);
             $checker = new Checker($subject, array('codiceFiscaleToCheck' => $data['codiceFiscale'], 'omocodiaLevel' => $data['omocodiaLevel']));
             if ($checker->check()) {
                 $response->status = true;
                 $response->message = 'Valid codice fiscale';
             } else {
                 $response->status = false;
                 $response->message = 'Invalid codice fiscale';
             }
         }
         return new JsonResponse($response);
     })->bind('apiCheck');
     return $api;
 }
Example #21
Show file File: OcFilter.php Project: jkhaled/OpenCartDoctrineSchema
0
 public function __construct(OcFilterGroup $filterGroup, Doctrine\Common\Collections\Collection $product, Doctrine\Common\Collections\Collection $category, $sortOrder)
 {
     $this->filterGroup = $filterGroup;
     $this->product = $product;
     $this->category = $category;
     $this->sortOrder = $sortOrder;
 }
Example #22
Show file File: CollectionTest.php Project: pimolo/monolol
0
 public function providerTestProviderCollection()
 {
     $emptyProvider = new QuoteProviders\EmptyQuoteProvider();
     $perceval = new QuoteProviders\Kaamelott\Perceval();
     $perceval2 = new QuoteProviders\Kaamelott\Perceval();
     $karadoc = new QuoteProviders\Kaamelott\Karadoc();
     $merlin = new QuoteProviders\Kaamelott\Merlin();
     $kadoc = new QuoteProviders\Kaamelott\Kadoc();
     $collectionA = new Collection();
     $collectionA->add($perceval)->add($karadoc);
     $collectionB = new Collection();
     $collectionB->add($merlin)->add($kadoc);
     return array('Empty + Empty' => array(array(), array($emptyProvider, $emptyProvider)), 'Same class, different instance' => array($perceval->getQuotes(), array($perceval, $perceval2)), 'Perceval + Empty' => array($perceval->getQuotes(), array($perceval, $emptyProvider)), 'Empty + Perceval' => array($perceval->getQuotes(), array($emptyProvider, $perceval)), 'Empty + Karadoc + Empty' => array($karadoc->getQuotes(), array($emptyProvider, $karadoc, $emptyProvider)), 'Perceval + Karadoc' => array(array_merge($perceval->getQuotes(), $karadoc->getQuotes()), array($perceval, $karadoc)), 'Perceval + Perceval + Karadoc' => array(array_merge($perceval->getQuotes(), $karadoc->getQuotes()), array($perceval, $perceval, $karadoc)), 'Collection + empty' => array($collectionA->getQuotes(), array($collectionA, $emptyProvider)), 'Collection + Kadoc' => array(array_merge($collectionA->getQuotes(), $kadoc->getQuotes()), array($collectionA, $kadoc)), 'Collection + Collection' => array(array_merge($collectionA->getQuotes(), $collectionB->getQuotes()), array($collectionA, $collectionB)));
 }