示例#1
0
 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int null or 0 if everything went fine, or an error code
  *
  * @throws LogicException When this abstract method is not implemented
  *
  * @see setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var QuestionHelper $helper */
     $helper = $this->getHelper('question');
     do {
         if (!isset($urlPath)) {
             $urlPath = $this->askUrlPath($helper, $input, $output);
         }
         if (!isset($presenter)) {
             $presenter = $this->askPresenter($helper, $input, $output);
         }
         if (!isset($internalID)) {
             $internalID = null;
             $internalIDConfirmation = new ConfirmationQuestion('Would you like to set Internal ID?', true);
             if ($helper->ask($input, $output, $internalIDConfirmation)) {
                 $internalID = $this->askInternalID($helper, $input, $output);
             }
         }
         $output->writeln(sprintf('Summary:
                  Url path: %s
                  Presenter: %s
                  internal ID: %s', $urlPath, $presenter, $internalID === null ? 'null' : $internalID));
         $anotherUrl = new ConfirmationQuestion('Do you want to save your Url?', true);
         if (!$helper->ask($input, $output, $anotherUrl)) {
             return;
         }
         try {
             $url = UrlGenerator::create($urlPath, $presenter, null, $internalID);
             $url = $this->em->safePersist($url);
             if ($url === false) {
                 $output->writeln(sprintf('Somebody has recently created an Url with path "%s".', $urlPath));
                 $changeQuestion = new ConfirmationQuestion('Do you want to change that Url path?', true);
                 if ($helper->ask($input, $output, $changeQuestion)) {
                     $urlPath = null;
                     continue;
                 }
                 $output->writeln(sprintf('Your Url couldn\'t have been saved because url with path "%s" already exists.', $urlPath));
                 return 1;
             }
             $output->writeln('New Url has been SUCCESSFULLY created!');
             $continueQuestion = new ConfirmationQuestion('Would you like to create another one?', true);
             if ($helper->ask($input, $output, $continueQuestion)) {
                 $urlPath = null;
                 $presenter = null;
                 $internalID = null;
                 continue;
             }
             return 0;
         } catch (\Exception $e) {
             $output->writeLn("That's bad. An Error occurred: <error>{$e->getMessage()}</error>");
             return -1;
         }
     } while (true);
 }
示例#2
0
 private function loadDefaultUrls(ObjectManager $manager)
 {
     $siteMap = UrlGenerator::create('sitemap.xml', 'Pages:Front:Page', 'sitemap');
     $manager->persist($siteMap);
     // FRONTEND
     $mainPage = UrlGenerator::create(' ', 'Pages:Front:Page', 'default');
     // empty string in urlPath
     $manager->persist($mainPage);
     $searchByTag = UrlGenerator::create('search', 'Pages:Front:Search', 'tag');
     // empty string in urlPath
     $manager->persist($searchByTag);
     // ADMINISTRATION
     $pageCreation = UrlGenerator::create('administration/article-creation', 'Pages:Admin:Page', 'new');
     $manager->persist($pageCreation);
     $pageEditing = UrlGenerator::create('administration/article-editing', 'Pages:Admin:Page', 'edit');
     $manager->persist($pageEditing);
     $pageRemoval = UrlGenerator::create('administration/article-removal', 'Pages:Admin:Page', 'remove');
     $manager->persist($pageRemoval);
     $pageOverview = UrlGenerator::create('administration/articles-overview', 'Pages:Admin:Page', 'overview');
     $manager->persist($pageOverview);
     $tags = UrlGenerator::create('administration/tags', 'Tags:Tag', 'default');
     $manager->persist($tags);
 }
示例#3
0
 private function loadDefaultUrls(ObjectManager $manager)
 {
     $login = UrlGenerator::create('administration/login', 'Users:Front:Auth', 'login');
     $manager->persist($login);
     $logout = UrlGenerator::create('administration/logout', 'Users:Front:Auth', 'logout');
     $manager->persist($logout);
     $users = UrlGenerator::create('administration/users', 'Users:Admin:Users', 'default');
     $manager->persist($users);
     $detail = UrlGenerator::create('administration/user-detail', 'Users:Admin:Users', 'detail');
     $manager->persist($detail);
     $userRemoval = UrlGenerator::create('administration/user-removal', 'Users:Admin:Users', 'userRemove');
     $manager->persist($userRemoval);
     $roles = UrlGenerator::create('administration/roles', 'Users:Admin:Users', 'roles');
     $manager->persist($roles);
     $newRole = UrlGenerator::create('administration/new-role', 'Users:Admin:Users', 'newRole');
     $manager->persist($newRole);
     $roleDefinition = UrlGenerator::create('administration/role-definition', 'Users:Admin:Users', 'roleDefinition');
     $manager->persist($roleDefinition);
     $roleRemoval = UrlGenerator::create('administration/role-removal', 'Users:Admin:Users', 'roleRemove');
     $manager->persist($roleRemoval);
 }
示例#4
0
 /**
  * @param Tag $tag
  */
 private function createUrl(Tag $tag)
 {
     $url = UrlGenerator::create(sprintf('search/%s', $tag->getName()), 'Pages:Front:Search', 'tag', $tag->getId());
     $this->urlFacade->saveUrl($url);
 }
示例#5
0
 private function loadDefaultUrls(ObjectManager $manager)
 {
     // ADMINISTRATION
     $images = UrlGenerator::create('administration/images', 'Images:Image', 'default');
     $manager->persist($images);
 }
示例#6
0
 private function loadDefaultUrls(ObjectManager $manager)
 {
     // ADMINISTRATION
     $options = UrlGenerator::create('administration/options', 'Options:Options', 'default');
     $manager->persist($options);
 }