Exemplo n.º 1
0
 /**
  * @param \Housekeeper\Contracts\Flow\Before $beforeFlow
  */
 public function handle(BeforeFlowContract $beforeFlow)
 {
     // Only affecting the first wrapped method
     if ($beforeFlow->getIndex() != 1) {
         return;
     }
     /**
      * @var \Housekeeper\Contracts\Repository|\Housekeeper\Abilities\Adjustable $repository
      */
     $repository = $beforeFlow->getRepository();
     $criterias = $repository->getCriterias();
     array_walk($criterias, function ($criteria) use($repository) {
         /**
          * @var \Housekeeper\Abilities\Adjustable\Contracts\Criteria $criteria
          */
         $repository->applyCriteria($criteria);
     });
 }
 /**
  * @param \Housekeeper\Contracts\Flow\Before $beforeFlow
  */
 public function handle(BeforeFlowContract $beforeFlow)
 {
     /**
      * Skip cache logic if cache has been disabled in the repository.
      *
      * @var $repository Repository|Statically
      */
     $repository = $beforeFlow->getRepository();
     if ($repository->isCacheEnabled() === false) {
         return;
     }
     /**
      * Only get cache when Action is typed as "READ".
      */
     if ($beforeFlow->getAction()->isType(Action::READ)) {
         $cached = $this->getCacheForAction($beforeFlow->getAction());
         if (!is_null($cached)) {
             $beforeFlow->setReturnValue($cached);
         }
     }
 }