public function setUp() { $testPimple = new \Pimple(); $testPimple['dewdrop-request'] = new Request(); require_once __DIR__ . '/../test-components/animals/Component.php'; $this->component = new \DewdropTest\Admin\Animals\Component($testPimple); $this->request = $this->component->getRequest(); $this->paths = $this->component->getPaths(); $this->isWp = $this->paths->isWp(); }
/** * Returns a page instance for the given name or false on failure * * @param string $name * @return \Dewdrop\Admin\Page\PageAbstract|false */ public function createPage($name) { // Remain compatible with WP style naming $name = $this->component->getInflector()->hyphenize($name); if (array_key_exists($name, $this->pageClassMap)) { $pageClass = $this->pageClassMap[$name]; $reflectedClass = new ReflectionClass($pageClass); return new $pageClass($this->component, $this->component->getRequest(), dirname($reflectedClass->getFileName()) . '/view-scripts'); } return false; }
public function createPage($name) { if ('upload' === $name) { $page = new UploadPage($this->component, $this->component->getRequest()); foreach ($this->fileHandlers as $fileHandler) { $page->addFileHandler($fileHandler); } return $page; } return false; }
public function setUp() { if (Env::getInstance() instanceof Zf1Env) { $this->markTestSkipped('Zend Framework 1 environment does not support ComponentAbstract.'); } $testPimple = new \Pimple(); $testPimple['dewdrop-request'] = new Request(); require_once __DIR__ . '/../test-components/animals/Component.php'; $this->component = new \DewdropTest\Admin\Animals\Component($testPimple); $this->request = $this->component->getRequest(); $this->paths = $this->component->getPaths(); $this->isWp = $this->paths->isWp(); }
/** * Check to see if this component is currently being accessed. We do this * manually because we want to know whether the component is in use before * WP would itself be able to tell us. This allows us to dispatch pages on * admin_init, which is early enough in the process that we can easily enqueue * other resources. Also, this gives us the chance to run code before WP has * rendered any output. * * * @return boolean */ protected function componentIsCurrentlyActive(ComponentAbstract $component) { return preg_match('/^' . $component->getSlug() . '($|\\/)/i', $component->getRequest()->getQuery('page')) || $component->getSlug() === $component->getRequest()->getPost('action'); }