コード例 #1
0
 public function inject($instance, ApplicationContext $context, BeanDefinition $bean)
 {
     if ($this->name == '') {
         throw new IocException("a property have no name in the bean ({$bean->getId()})");
     }
     if ($this->value) {
         $value = $value = $this->getValueProperty($context, $this->value);
     } elseif ($this->ref) {
         $value = ContainerFactory::getBean($this->ref);
     } else {
         $value = null;
     }
     $this->injectProperty($instance, $value, $bean);
 }
コード例 #2
0
 public function testSetterWithPrivate()
 {
     $test = ContainerFactory::getBean('test3');
     $this->assertEquals(666, $test->getPriv());
 }
コード例 #3
0
 public function testContainerHasYamlService()
 {
     // Given: Container
     $container = ContainerFactory::build();
     // Then: Expect to have defined yaml service
     $this->assertTrue($container->has('yaml'));
     // Then: Expect to yaml service be set as shared
     $this->assertTrue($container->getService('yaml')->isShared());
     // Then: Expect to have yaml be instance of Symfony\Component\Yaml\Parser
     $this->assertInstanceOf('Symfony\\Component\\Yaml\\Parser', $container->get('yaml'));
     // Cleanup: Reset default Phalcon instance
     DI::reset();
 }
コード例 #4
0
 public function inject($instance, ApplicationContext $context, BeanDefinition $bean)
 {
     $value = ContainerFactory::getBean($this->ref);
     $setter = $this->name;
     $instance->{$setter}($value);
 }
コード例 #5
0
 public function inject($instance, ApplicationContext $context, BeanDefinition $bean)
 {
     $value = ContainerFactory::getBean($this->ref);
     $propertyName = $this->name;
     $instance->{$propertyName} = $value;
 }
コード例 #6
0
ファイル: index.php プロジェクト: bachkoutou/Simple-MVC
autoloadManager::addFolder(BUSINESS);
spl_autoload_register('autoloadManager::loadClass');
$_REQUEST['controller'] = Toolbox::getArrayParameter($_REQUEST, 'controller', 'Feed');
$_REQUEST['action'] = Toolbox::getArrayParameter($_REQUEST, 'action', 'index');
// jquery based ajax application
$from = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['HTTP_X_REQUESTED_WITH'] ? 'ajax' : 'http';
try {
    $front = frontDispatcher::getInstance();
    // Init Session
    // Save header for ajax call, so that we can either root or return false for ajax calls
    $actions = AccessHelper::getActions();
    // authenticate
    $AuthManager = new AuthManager($actions);
    $AuthManager->authenticate($front, '/?controller=Feed&action=index', $from);
    // Inject Dynamically changing objects
    $Container = ContainerFactory::get('front');
    $Container['Access'] = $actions;
    $Container['AuthManager'] = $AuthManager;
    $Container['Request'] = $_REQUEST;
    $Container['Session'] = SessionManager::getSession('front');
    // Route
    $front->route($Container);
} catch (Exception $e) {
    if ('ajax' == $from) {
        header('content-type: application/json');
        $params = array('error' => 'false', 'message' => $e->getMessage());
        echo json_encode($params);
        exit;
    } else {
        $console = new DebugConsole($e, true);
        $console->render();
コード例 #7
0
ファイル: woodlets.php プロジェクト: neochic/woodlets
Text Domain: Neochic\Woodlets
*/
namespace Neochic\Woodlets;

/*
 * don't do anything if not called from WordPress
 * https://codex.wordpress.org/Writing_a_Plugin
 */
defined('ABSPATH') or die('No script kiddies please!');
/*
 * wrapped to keep global namespace clean
 */
call_user_func(function () {
    /*
     * include composer autoloader if packaged version is used
     * if installed via composer autoloader should already be added
     */
    $autoloader = __DIR__ . '/vendor/autoload.php';
    if (is_file($autoloader)) {
        require_once $autoloader;
    }
    /*
     * initialize woodlets
     */
    $container = ContainerFactory::createContainer();
    $container['autoloader'] = $autoloader;
    $container['basedir'] = __DIR__;
    $container['baseurl'] = plugins_url('', __FILE__);
    $woodlets = $container['woodlets'];
    $woodlets->init();
});