Пример #1
0
 /**
  * @param AdminController $fromController
  * @param array           $destination
  * @param $function
  * @param array $flags
  *
  * @throws \Just\Shapeshifter\Exceptions\MethodNotExistException
  */
 public function __construct(AdminController $fromController, $destination, $function, $flags = [])
 {
     $this->destination = 'admin.' . $destination . '.index';
     $this->destination = $this->setupDestination();
     $this->fromcontroller = $fromController;
     $this->model = $fromController->getRepo()->getModel();
     $this->function = $function;
     $this->name = $destination;
     $this->flags = $flags;
     $this->foreign = $this->name = $this->getForeignField();
 }
 /**
  * @param AdminController $fromController
  * @param string          $destination
  * @param string          $function
  * @param array           $flags
  *
  * @throws ShapeShifterException
  */
 public function __construct(AdminController $fromController, $destination, $function, $flags = [])
 {
     $routes = Route::getRoutes();
     $this->destination = 'admin.' . $destination . '.index';
     $this->destination = $this->resolveControllerByName($routes);
     $this->fromcontroller = $fromController;
     if ($current = $this->getCurrentRecordId()) {
         $repo = $fromController->getRepo();
         $this->model = $repo->findById($current);
         if (null == $this->model) {
             throw new ShapeShifterException(sprintf('Model [%s] with id [%s] doesn\'t exist', get_class($repo->getModel()), $current));
         }
     }
     $this->function = $function;
     $this->name = $this->destination->getTitle();
     $this->flags = array_merge($flags, ['hide_list']);
 }
Пример #3
0
 /**
  * @param $ref
  */
 protected function checkEventActions(AdminController $ref)
 {
     if (null === $ref->getParent()) {
         $this->model = !$this->model->id ? $ref->beforeAdd($this->model) : $ref->beforeUpdate($this->model);
     } else {
         $ref->getMode() === 'store' ? $ref->beforeAdd($this->model) : $ref->beforeUpdate($this->model);
     }
 }
Пример #4
0
 /**
  * @return mixed
  */
 public function getDestinationName()
 {
     return $this->destination->getTitle();
 }