示例#1
0
 public function performAction()
 {
     if (!($user = AuthService::getInstance()->getUser())) {
         throw new \Exception('Authenticated user required');
     }
     $this->response->success('CATALOGE!');
     /** @var Album[] $albums */
     $albums = Album::statement()->where('? = ?', Album::columns()->userId, $user->id)->query()->fetchAll();
     $this->response->addContent(new Form(Create::createState(), $this->io));
     $details = Details::createState();
     if ($albums) {
         $this->response->addContent(new Rows(Processor::create($albums)->map(function (Album $album) use($details) {
             $row = array();
             $details->albumId = $album->id;
             $anchor = $this->io->makeAnchor($details);
             $row['Title'] = new Anchor($album->title, $anchor);
             $row['Created'] = date('Y-m-d H:i:s', $album->created);
             $row['Updated'] = date('Y-m-d H:i:s', $album->updated);
             $row['Images'] = $album->imagesCount;
             return $row;
         })));
     }
 }
示例#2
0
 static function setUpDefinition(Definition $definition, $options)
 {
     $options->action = Option::create(EnumActions::create()->addToEnum(Catalog::definition(), '')->addToEnum(Create::definition())->addToEnum(Details::definition())->addToEnum(Upload::definition()))->setIsUnnamed()->setIsRequired();
 }