public function setUp() { $stub = \Mockery::mock('UrlGenerator'); $stub->shouldReceive(['url' => '']); RegistryFactory::start()->set('url', $stub); $this->bc = new Breadcrumbs(); }
/** * * @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; }
/** * * @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(); }
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'); }
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'); }
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(); }
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(); }
private function setSession() { if ($this->remember) { RegistryFactory::start('cookie')->set('userSession', $this->userEntity); } else { RegistryFactory::start('session')->set('userSession', $this->userEntity); } }
/** * * @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); } }
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(); }
/** * * @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(); }
/** * 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); }
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(); }
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); }
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; } }
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(); }
/** * * @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); }
/** * * @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; } }
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); }
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(); }
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()); }
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(); }
public function __construct() { $this->conf = RegistryFactory::start('file')->register('Conf\\Conf'); $this->http = RegistryFactory::start()->get('http'); }
public function __construct() { $this->query = RegistryFactory::start()->register('DataBase\\Query\\Query'); }
/** * @expectedException \Ignaszak\Registry\RegistryException */ public function testStartException() { RegistryFactory::start('incorrectArgument'); }
public function __construct() { $this->registry = RegistryFactory::start(); }
/** * @return boolean */ private function isPostOpen() { return RegistryFactory::start()->get('http')->router->name() === 'post-alias'; }
/** * * @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(); }
/** * 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); }
/** * @return array */ protected function getHome() : array { return [$this->addBreadcrumb('Home', $this->registry->get('url')->url('default'))]; }