Esempio n. 1
0
 public function setUp()
 {
     $stub = \Mockery::mock('UrlGenerator');
     $stub->shouldReceive(['url' => '']);
     RegistryFactory::start()->set('url', $stub);
     $this->bc = new Breadcrumbs();
 }
Esempio n. 2
0
 /**
  *
  * @param string $name entity name from \Entity\Controller\EntityController
  * @return IQueryController
  */
 public function setQuery(string $name) : IQueryController
 {
     $entityController = RegistryFactory::start()->register('Entity\\Controller\\EntityController');
     $entityName = $entityController->getEntity($name);
     $this->queryController = new QueryController($entityName);
     return $this->queryController;
 }
Esempio n. 3
0
 /**
  *
  * @param \Form\Form $form
  */
 public function __construct(\Form\Form $form)
 {
     $this->form = $form;
     $this->conf = RegistryFactory::start('file')->register('Conf\\Conf');
     $this->url = RegistryFactory::start()->get('url');
     $this->formAction = $this->getFormAction();
 }
Esempio n. 4
0
 public function __construct()
 {
     $this->conf = RegistryFactory::start('file')->register('Conf\\Conf');
     $registry = RegistryFactory::start();
     $this->query = $registry->register('DataBase\\Query\\Query');
     $this->url = $registry->get('url');
 }
Esempio n. 5
0
 public function __construct()
 {
     $this->conf = RegistryFactory::start('file')->register('Conf\\Conf');
     $registry = RegistryFactory::start();
     $this->categoryList = $registry->register('App\\Resource\\CategoryList')->get();
     $this->url = $registry->get('url');
 }
Esempio n. 6
0
 public function __construct()
 {
     $this->registry = RegistryFactory::start();
     $this->conf = RegistryFactory::start('file')->register('Conf\\Conf');
     $this->http = $this->registry->get('http');
     $this->setParams();
     $this->createPaginationArray();
 }
Esempio n. 7
0
 public function __construct()
 {
     $registry = RegistryFactory::start();
     $this->http = $registry->get('http');
     $this->query = RegistryFactory::start()->register('DataBase\\Query\\Query');
     $this->query->setQuery('category');
     $this->categoryArray = $this->query->getStaticQuery();
 }
Esempio n. 8
0
 private function setSession()
 {
     if ($this->remember) {
         RegistryFactory::start('cookie')->set('userSession', $this->userEntity);
     } else {
         RegistryFactory::start('session')->set('userSession', $this->userEntity);
     }
 }
Esempio n. 9
0
 /**
  *
  * @param \Entity\Users $userEntity
  */
 private function reloadUserSession(\Entity\Users $userEntity)
 {
     if (RegistryFactory::start('session')->get('userSession')) {
         RegistryFactory::start('session')->set('userSession', $userEntity);
     } else {
         RegistryFactory::start('cookie')->set('userSession', $userEntity);
     }
 }
Esempio n. 10
0
 public function __construct(string $entityName)
 {
     $this->conf = RegistryFactory::start('file')->register('Conf\\Conf');
     $this->http = RegistryFactory::start()->get('http');
     $this->queryBuilder = new QueryBuilder($this);
     $this->entityName = $entityName;
     $this->createQuery();
 }
Esempio n. 11
0
 /**
  *
  * @param ViewHelper $viewHelper
  */
 public function __construct(ViewHelper $viewHelper)
 {
     $this->registry = RegistryFactory::start();
     $this->viewHelper = $viewHelper;
     $this->http = $this->registry->get('http');
     $this->conf = new Conf();
     $this->conf->configureThemePath();
 }
Esempio n. 12
0
 /**
  * Inserts mock entity to \Entity\Controller\EntityController
  *
  * @param string $name
  * @param string|Entity $stub
  */
 public static function mock(string $name, $stub)
 {
     $entityController = RegistryFactory::start()->register('Entity\\Controller\\EntityController');
     if (is_object($stub)) {
         $stub = get_class($stub);
     }
     $entityController->addEntity($name, $stub);
 }
Esempio n. 13
0
 public function run()
 {
     if ($this->registry->get('user')->isUserLoggedIn()) {
         RegistryFactory::start('cookie')->remove('userSession');
         RegistryFactory::start('session')->remove('userSession');
     }
     Server::setReferData(['search' => Server::getReferData()['search']]);
     Server::headerLocationReferer();
 }
Esempio n. 14
0
 public static function run()
 {
     $stub = \Mockery::mock('Http');
     $stub->shouldReceive('isAdmin')->andReturnUsing(function () : bool {
         return (bool) preg_match('/^admin-[a-zA-Z0-9_-]*/', self::$routerResponse['name']);
     });
     $stub->router = self::mockRouter();
     RegistryFactory::start()->set('http', $stub);
 }
Esempio n. 15
0
 public function catchUserSession()
 {
     $session = RegistryFactory::start('session')->get('userSession');
     $cookie = RegistryFactory::start('cookie')->get('userSession');
     if ($session instanceof \Entity\Users) {
         $this->userSession = $session;
     } elseif ($cookie instanceof \Entity\Users) {
         $this->userSession = $cookie;
     }
 }
Esempio n. 16
0
 public function run()
 {
     $adminMail = RegistryFactory::start('file')->register('Conf\\Conf')->getAdminEmail();
     $transport = \Swift_MailTransport::newInstance();
     $message = \Swift_Message::newInstance()->setSubject('Message from CMS')->setFrom($this->http->request->get('from'))->setTo($adminMail)->setBody($this->http->request->get('body'));
     $mailer = \Swift_Mailer::newInstance($transport);
     $mailer->send($message);
     Server::setReferData(['send' => 1]);
     Server::headerLocationReferer();
 }
Esempio n. 17
0
 /**
  *
  * @param \Entity $entity
  * @param Validator\Schema\Validation $schema
  */
 public function __construct($entity, Validator\Schema\Validation $schema = null)
 {
     $this->entity = $entity;
     $this->entityName = get_class($this->entity);
     $this->em = DBDoctrine::em();
     $this->entityController = RegistryFactory::start()->register('Entity\\Controller\\EntityController');
     if (is_null($schema)) {
         $schema = new Validator\Schema\Validation();
     }
     $this->validatorFactory = new Validator\ValidatorFactory($this, $schema);
 }
Esempio n. 18
0
 /**
  *
  * @param string $location
  */
 public static function headerLocation(string $location = '/')
 {
     self::setRefererSession();
     if (!defined('TEST')) {
         if (strpos($location, 'http') === false) {
             $location = RegistryFactory::start('file')->register('Conf\\Conf')->getBaseUrl() . $location;
         }
         header('Location: ' . $location);
         exit;
     }
 }
Esempio n. 19
0
 public static function run(array $data = null)
 {
     $_conf = RegistryFactory::start('file')->register('Conf\\Conf');
     $array = ['getId' => null, 'getSiteTitle' => '', 'getAdminEmail' => '', 'getViewLimit' => null, 'getDateFormat' => '', 'getBaseUrl' => '', 'getRequestUri' => '', 'getTheme' => ''];
     if (!is_null($data)) {
         foreach ($data as $key => $value) {
             $array[$key] = $value;
         }
     }
     MockTest::inject($_conf, 'optionsArray', $array);
 }
Esempio n. 20
0
 public static function setUpBeforeClass()
 {
     $stub = \Mockery::mock('alias:MenuItems');
     $stub->shouldReceive(['getAdress', 'getTitle', 'getMenuItems' => $stub]);
     $value = MockQuery::getQuery([$stub]);
     RegistryFactory::start()->set('DataBase\\Query\\Query', $value);
     MockDoctrine::queryBuilderResult([null]);
     MockDoctrine::getRepositoryResult([null]);
     MockConf::run();
     // Sets site adress as '';
     self::$menu = new Menu();
 }
Esempio n. 21
0
    public function testActive()
    {
        RegistryFactory::start()->set('http', $this->mockHttp('Page', 'admin-post-add'));
        $structure = ['Post' => ['conf.yml' => ''], 'Page' => ['conf.yml' => <<<EOT
menu:
    - {title: Add new post, url: admin-post-add, tokens: {action: add}}
    - {title: Add new post 2, url: admin-post-add-2, tokens: {action: add-2}}
EOT
]];
        $this->admin = new Admin($this->mockAdminExtension(MockTest::mockFileSystem($structure), ['Post', 'Page']), new Yaml());
        $this->assertEquals([0 => ['active' => false], 1 => ['active' => true, 'menu' => [0 => ['active' => true, 'title' => 'Add new post', 'url' => 'generatedUrl'], 1 => ['active' => false, 'title' => 'Add new post 2', 'url' => 'generatedUrl']]]], $this->admin->getAdminMenu());
    }
Esempio n. 22
0
 private function selectPosts()
 {
     switch ($this->http->router->group()) {
         case 'post':
             $this->query->setQuery('post');
             break;
         case 'category':
             $catIdArray = RegistryFactory::start()->register('App\\Resource\\CategoryList')->child();
             $this->query->setQuery('post')->categoryId($catIdArray)->force();
             break;
         case 'date':
             $this->query->setQuery('post')->date($this->getDate())->force();
             break;
         default:
             $this->query->setQuery('post');
     }
     $this->post = $this->query->getQuery();
 }
Esempio n. 23
0
 public function __construct()
 {
     $this->conf = RegistryFactory::start('file')->register('Conf\\Conf');
     $this->http = RegistryFactory::start()->get('http');
 }
Esempio n. 24
0
 public function __construct()
 {
     $this->query = RegistryFactory::start()->register('DataBase\\Query\\Query');
 }
 /**
  * @expectedException \Ignaszak\Registry\RegistryException
  */
 public function testStartException()
 {
     RegistryFactory::start('incorrectArgument');
 }
Esempio n. 26
0
 public function __construct()
 {
     $this->registry = RegistryFactory::start();
 }
Esempio n. 27
0
 /**
  * @return boolean
  */
 private function isPostOpen()
 {
     return RegistryFactory::start()->get('http')->router->name() === 'post-alias';
 }
Esempio n. 28
0
 /**
  *
  * @return Controller
  */
 public static function instance() : Controller
 {
     $registry = RegistryFactory::start();
     self::$instances = ['registry' => $registry, 'http' => $registry->get('http'), 'view' => $registry->get('view'), 'query' => $registry->register('DataBase\\Query\\Query')];
     return new static();
 }
Esempio n. 29
0
 /**
  * Configures and loads http
  * @link https://github.com/ignaszak/php-router
  */
 public function loadHttp()
 {
     $yaml = new RouterYaml();
     $yaml->add($this->routerYaml);
     $adminYaml = $this->adminExtension->getAdminExtensionsRouteYaml();
     foreach ($adminYaml as $file) {
         $yaml->add($file);
     }
     $cache = new Cache($yaml);
     $cache->tmpDir = $this->dir($this->conf['conf']['tmp']['router'] ?? '');
     $matcher = new Matcher($cache);
     $host = new Host(RegistryFactory::start('file')->register('Conf\\Conf')->getRequestUri());
     $response = new Response($matcher->match($host));
     $this->registry->set('url', new UrlGenerator($cache, $host));
     $this->http = new Http($response, Request::createFromGlobals());
     $this->registry->set('http', $this->http);
 }
Esempio n. 30
0
 /**
  * @return array
  */
 protected function getHome() : array
 {
     return [$this->addBreadcrumb('Home', $this->registry->get('url')->url('default'))];
 }