コード例 #1
0
ファイル: Admin.php プロジェクト: deltasystems/dewdrop
 public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
 {
     $this->pimple = Pimple::getInstance();
     if ($this instanceof CrudInterface) {
         $this->addPageFactory(new CrudFactory($this));
     }
     $this->env = new Zf1AdminEnv($this);
     parent::__construct($request, $response, $invokeArgs);
 }
コード例 #2
0
 /**
  * @expectedException \Dewdrop\Exception
  */
 public function testComponentWithEmptyInitThrowsException()
 {
     require_once __DIR__ . '/../test-components/insufficient-init-method/Component.php';
     new \DewdropTest\Admin\InsufficientInitMethod\Component(Pimple::getInstance());
 }
コード例 #3
0
<?php

// On prod, most code is tucked into zend outside the doc root
if (file_exists(__DIR__ . '/../zend/')) {
    define('APPLICATION_PATH', realpath(__DIR__ . '/../zend/'));
} else {
    define('APPLICATION_PATH', realpath(__DIR__ . '/../'));
}
require_once APPLICATION_PATH . '/vendor/autoload.php';
use Dewdrop\Pimple;
/* @var $silex \Silex\Application */
$silex = Pimple::getInstance();
$silex->get('/', function () {
    return file_get_contents(__DIR__ . '/dewdrop-index.html');
});
Pimple::getResource('admin')->registerComponentsInPath();
$silex->run();
コード例 #4
0
ファイル: Index.php プロジェクト: bravadomizzou/dewdrop
 /**
  * Ensure the user is allowed to view the listing in this component.
  */
 public function init()
 {
     $this->component->getPermissions()->haltIfNotAllowed('view-listing');
     $this->session = new Session(Pimple::getInstance());
     $this->session->set($this->component->getListingQueryParamsSessionName(), $this->request->getQuery());
 }
コード例 #5
0
ファイル: Run.php プロジェクト: bravadomizzou/dewdrop
 /**
  * Create the CLI runner, giving users the ability to inject non-default
  * args, command name, and renderer (primarily for testing purposes).
  *
  * @param array $args
  * @param string $command
  * @param RendererInterface $renderer
  */
 public function __construct(array $args = null, $command = null, $renderer = null)
 {
     $this->pimple = DewdropPimple::getInstance();
     $this->args = $args ?: array_slice($_SERVER['argv'], 2);
     $this->renderer = $renderer ?: new Renderer\Markdown();
     $this->paths = isset($this->pimple['paths']) ? $this->pimple['paths'] : new Paths();
     if ($command) {
         $this->command = $command;
     } elseif (isset($_SERVER['argv'][1])) {
         $this->command = $_SERVER['argv'][1];
     }
 }
コード例 #6
0
ファイル: Table.php プロジェクト: bravadomizzou/dewdrop
 /**
  * If this table has date_updated or datetime_updated columns, supply a
  * value for them automatically during update(). It also will assign
  * the current user ID as the updater if possible.
  *
  * @param array $data
  * @return array
  */
 public function augmentUpdatedDataArrayWithWhenAndByWhom(array $data)
 {
     // When
     if ($this->getMetadata('columns', 'date_updated')) {
         $data['date_updated'] = date('Y-m-d G:i:s');
     } elseif ($this->getMetadata('columns', 'datetime_updated')) {
         $data['datetime_updated'] = date('Y-m-d G:i:s');
     } elseif ($this->getMetadata('columns', 'updated_at')) {
         $data['updated_at'] = date('Y-m-d H:i:s');
     }
     // By whom
     /* @var \Dewdrop\Pimple $pimple */
     $pimple = Pimple::getInstance();
     /* @var \Dewdrop\Paths $paths */
     $paths = $pimple['paths'];
     if ($this->getMetadata('columns', 'updated_by_user_id')) {
         if ($paths->isWp()) {
             $data['updated_by_user_id'] = get_current_user_id();
         } elseif (Pimple::hasResource('user') && ($user = Pimple::getResource('user')) && isset($user['user_id']) && 0 < $user['user_id']) {
             $data['updated_by_user_id'] = $user['user_id'];
         }
     }
     return $data;
 }
コード例 #7
0
 /**
  * Create a component instance using the DB adapter creating by the Wiring
  * class.
  *
  * @param Pimple $pimple
  * @param string $componentName
  */
 public function __construct(Pimple $pimple = null)
 {
     $this->pimple = $pimple ?: DewdropPimple::getInstance();
     $this->env = $this->getPimpleResource('admin');
     // Component metadata retrieved via reflection
     $reflectionClass = new ReflectionClass($this);
     $this->path = dirname($reflectionClass->getFileName());
     $this->name = basename($this->path);
     // Setup the default page factory, which looks for files in the component's folder
     $this->addPageFactory(new PageFilesFactory($this));
     if (isset($pimple['custom-page-factory'])) {
         $this->customPageFactory = $this->pimple['custom-page-factory'];
         $this->customPageFactory->setComponent($this);
         $this->addPageFactory($this->customPageFactory);
     }
     $this->init();
     $this->checkRequiredProperties();
 }
コード例 #8
0
ファイル: EnvAbstract.php プロジェクト: deltasystems/dewdrop
 /**
  * Register the single admin component located in the supplied path.  This
  * can be useful if you want to register individual components that are
  * outside your normal folder for admin components.  For example, if you've
  * got some reuseable admin components in a library, or Dewdrop itself, you
  * could register them with this method.
  *
  * @param string $folder
  * @param string $classPrefix
  * @return EnvAbstract
  */
 public function registerComponentFolder($folder, $classPrefix = '\\Admin\\')
 {
     require_once $folder . '/Component.php';
     $componentName = basename($folder);
     $className = $classPrefix . Pimple::getResource('inflector')->camelize($componentName) . '\\Component';
     $component = new $className(Pimple::getInstance());
     return $this->registerComponent($component);
 }
コード例 #9
0
 /**
  * Create a component instance using the DB adapter creating by the Wiring
  * class.
  *
  * @param Pimple $pimple
  * @param string $componentName
  */
 public function __construct(Pimple $pimple = null)
 {
     $this->pimple = $pimple ?: DewdropPimple::getInstance();
     $this->env = $this->getPimpleResource('admin');
     $this->activityLogHandler = new ActivityLogNullHandler();
     // Setup the default page factory, which looks for files in the component's folder
     $this->addPageFactory(new PageFilesFactory($this));
     if (isset($pimple['custom-page-factory'])) {
         $this->customPageFactory = $this->pimple['custom-page-factory'];
         $this->customPageFactory->setComponent($this);
         $this->addPageFactory($this->customPageFactory);
     }
     $this->init();
     $this->checkRequiredProperties();
 }
コード例 #10
0
ファイル: Edit.php プロジェクト: bravadomizzou/dewdrop
 protected function redirect(ResponseHelper $responseHelper)
 {
     $session = new Session(Pimple::getInstance());
     $index = $this->component->getListingQueryParamsSessionName();
     $params = isset($session[$index]) ? $session[$index] : [];
     if (!is_array($params)) {
         $params = (array) $params;
     }
     $responseHelper->redirectToAdminPage('index', $params);
 }
コード例 #11
0
<?php

/**
 * Plugin Name: Dewdrop Skeleton Project
 * Description: A new plugin created from the Dewdrop project skeleton.
 * Version: 1.0
 */
use Dewdrop\Pimple;
require_once __DIR__ . '/vendor/autoload.php';
$pimple = Pimple::getInstance();
$pimple['view'] = function () {
    $view = new \Dewdrop\View\View();
    return $view;
};
$pimple['admin']->registerComponentsInPath();