当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper\Set类代码示例

本文整理汇总了PHP中Slim\Helper\Set的典型用法代码示例。如果您正苦于以下问题:PHP Set类的具体用法?PHP Set怎么用?PHP Set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Set类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 public function get()
 {
     $request = $this->getSlim()->request();
     // Check authentication
     $this->getSlim()->auth->checkPermission('profile');
     // TODO: Validation.
     $params = new Set($request->get());
     $agent = $params->get('agent');
     $agent = json_decode($agent, true);
     $view = new AgentView(['agent' => $agent]);
     $view = $view->renderGet();
     Resource::jsonResponse(Resource::STATUS_OK, $view);
 }
开发者ID:rohanabraham,项目名称:lxHive,代码行数:13,代码来源:Agents.php

示例2: activityGet

 /**
  * Fetches activity profiles according to the given parameters.
  *
  * @param array $request The incoming HTTP request
  *
  * @return array An array of activityProfile objects.
  */
 public function activityGet($request)
 {
     $params = new Set($request->get());
     $collection = $this->getDocumentManager()->getCollection('activities');
     $cursor = $collection->find();
     $cursor->where('id', $params->get('activityId'));
     if ($cursor->count() === 0) {
         throw new Exception('Activity does not exist.', Resource::STATUS_NOT_FOUND);
     }
     $this->cursor = $cursor;
     $this->single = true;
     return $this;
 }
开发者ID:rohanabraham,项目名称:lxHive,代码行数:20,代码来源:Activity.php

示例3: set

 /**
  * Set cookie
  *
  * The second argument may be a single scalar value, in which case
  * it will be merged with the default settings and considered the `value`
  * of the merged result.
  *
  * The second argument may also be an array containing any or all of
  * the keys shown in the default settings above. This array will be
  * merged with the defaults shown above.
  *
  * @param string $key   Cookie name
  * @param mixed  $value Cookie settings
  */
 public function set($key, $value)
 {
     if (is_array($value)) {
         $cookieSettings = array_replace($this->defaults, $value);
     } else {
         $cookieSettings = array_replace($this->defaults, array('value' => $value));
     }
     parent::set($key, $cookieSettings);
 }
开发者ID:patrickglasgow,项目名称:HonsProject,代码行数:23,代码来源:Cookies.php

示例4: configureIoc

 /**
  * Configure inversion of control/dependency injection container.
  *
  * @param \Slim\Helper\Set $container IOC container
  */
 protected function configureIoc(\Slim\Helper\Set $container)
 {
     $container->singleton('i18nCache', function ($c) {
         return new JsonCache($c->settings['i18n.path'], $c->log);
     });
     $container->singleton('i18nContext', function ($c) {
         return new I18nContext($c->i18nCache, $c->settings['i18n.default'], $c->log);
     });
     $container->singleton('mailer', function ($c) {
         return new Mailer(array('Host' => $c->settings['smtp.host']), $c->log);
     });
     $container->singleton('parsoid', function ($c) {
         return new ParsoidClient($c->settings['parsoid.url'], $c->settings['parsoid.cache'], $c->log);
     });
     $container->singleton('quips', function ($c) {
         $settings = array('url' => $c->settings['es.url'], 'log' => true);
         if ($c->settings['es.user'] !== '') {
             $creds = base64_encode($c->settings['es.user'] . ':' . $c->settings['es.password']);
             $settings['headers'] = array('Authorization' => "Basic {$creds}");
         }
         $client = new \Elastica\Client($settings);
         $client->setLogger($c->log);
         return new Quips($client, $c->log);
     });
     $container->singleton('oauthConfig', function ($c) {
         $conf = new \MediaWiki\OAuthClient\ClientConfig($c->settings['oauth.endpoint']);
         $conf->setRedirURL($c->settings['oauth.redir']);
         $conf->setConsumer(new \MediaWiki\OAuthClient\Consumer($c->settings['oauth.consumer_token'], $c->settings['oauth.secret_token']));
         return $conf;
     });
     $container->singleton('oauthClient', function ($c) {
         $client = new \MediaWiki\OAuthClient\Client($c->oauthConfig, $c->log);
         $client->setCallback($c->settings['oauth.callback']);
         return $client;
     });
     $container->singleton('userManager', function ($c) {
         return new OAuthUserManager($c->oauthClient, $c->log);
     });
     $container->singleton('authManager', function ($c) {
         return new AuthManager($c->userManager);
     });
     // TODO: figure out where to send logs
 }
开发者ID:bd808,项目名称:quips,代码行数:48,代码来源:App.php

示例5: get

 public function get()
 {
     $request = $this->getSlim()->request();
     // Check authentication
     $this->getSlim()->auth->checkPermission('attachments');
     $params = new Set($request->get());
     if (!$params->has('sha2')) {
         throw new \Exception('Missing sha2 parameter!', Resource::STATUS_BAD_REQUEST);
     }
     $sha2 = $params->get('sha2');
     $encoding = $params->get('encoding');
     // Fetch attachment metadata and data
     $metadata = $this->attachmentService->fetchMetadataBySha2($sha2);
     $data = $this->attachmentService->fetchFileBySha2($sha2);
     if ($encoding !== 'binary') {
         $data = base64_encode($data);
     }
     $this->getSlim()->response->headers->set('Content-Type', $metadata->getContentType());
     Resource::response(Resource::STATUS_OK, $data);
 }
开发者ID:rohanabraham,项目名称:lxHive,代码行数:20,代码来源:Attachments.php

示例6: loginPost

 /**
  * Logs the user in.
  *
  * @return \API\Document\User The user document
  */
 public function loginPost($request)
 {
     $params = new Set($request->post());
     // CSRF protection
     if (!$params->has('csrfToken') || !isset($_SESSION['csrfToken']) || $params->get('csrfToken') !== $_SESSION['csrfToken']) {
         throw new \Exception('Invalid CSRF token.', Resource::STATUS_BAD_REQUEST);
     }
     // This could be in JSON schema as well :)
     if (!$params->has('email') || !$params->has('password')) {
         throw new \Exception('Username or password missing!', Resource::STATUS_BAD_REQUEST);
     }
     $collection = $this->getDocumentManager()->getCollection('users');
     $cursor = $collection->find();
     $cursor->where('email', $params->get('email'));
     $cursor->where('passwordHash', sha1($params->get('password')));
     $document = $cursor->current();
     if (null === $document) {
         $errorMessage = 'Invalid login attempt. Try again!';
         $this->errors[] = $errorMessage;
         throw new \Exception($errorMessage, Resource::STATUS_UNAUTHORIZED);
     }
     $this->single = true;
     $this->users = [$document];
     // Set the session
     $_SESSION['userId'] = $document->getId();
     $_SESSION['expiresAt'] = time() + 3600;
     //1 hour
     // Set the Remember me cookie
     $rememberMeStorage = new RemembermeMongoStorage($this->getDocumentManager());
     $rememberMe = new Rememberme\Authenticator($rememberMeStorage);
     if ($params->has('rememberMe')) {
         $rememberMe->createCookie($document->getId());
     } else {
         $rememberMe->clearCookie();
     }
     return $document;
 }
开发者ID:rohanabraham,项目名称:lxHive,代码行数:42,代码来源:User.php

示例7: configureIoc

 /**
  * Configure inversion of control/dependency injection container.
  *
  * @param \Slim\Helper\Set $container IOC container
  */
 protected function configureIoc(\Slim\Helper\Set $container)
 {
     $container->singleton('i18nCache', function ($c) {
         return new JsonCache($c->settings['i18n.path'], $c->log);
     });
     $container->singleton('i18nContext', function ($c) {
         return new I18nContext($c->i18nCache, $c->settings['i18n.default'], $c->log);
     });
     $container->singleton('mailer', function ($c) {
         return new Mailer(['Host' => $c->settings['smtp.host']], $c->log);
     });
     $container->singleton('parsoid', function ($c) {
         return new ParsoidClient($c->settings['parsoid.url'], $c->settings['parsoid.cache'], $c->log);
     });
     $container->singleton('logs', function ($c) {
         return new Logs(new \Elastica\Client(['url' => $c->settings['es.url']]), $c->log);
     });
     // TODO: figure out where to send logs
 }
开发者ID:bd808,项目名称:SAL,代码行数:24,代码来源:App.php

示例8: testConsumeSlimContainer

 public function testConsumeSlimContainer()
 {
     $anoterContainer = new Set();
     $anoterContainer->foo = [];
     $anoterContainer->bar = new \stdClass();
     $anoterContainer->baz = function ($c) {
         return 'Hello';
     };
     $anoterContainer->singleton('foobar', function ($c) {
         return 'Hello';
     });
     $anoterContainer->barfoo = [$this, 'fakeMethod'];
     $this->container->consumeSlimContainer($anoterContainer);
     $this->assertTrue($this->sm->has('foo'));
     $this->assertTrue($this->container->has('foo'));
     $this->assertTrue($this->sm->has('bar'));
     $this->assertTrue($this->container->has('bar'));
     $this->assertTrue($this->sm->has('baz'));
     $this->assertTrue($this->container->has('baz'));
     $this->assertTrue($this->sm->has('foobar'));
     $this->assertTrue($this->container->has('foobar'));
     $this->assertTrue($this->sm->has('barfoo'));
     $this->assertTrue($this->container->has('barfoo'));
 }
开发者ID:acelaya,项目名称:slim-container-sm,代码行数:24,代码来源:ContainerTest.php

示例9: accessTokenDelete

 /**
  * Tries to delete an access token.
  */
 public function accessTokenDelete($request)
 {
     $params = new Set($request->get());
     $this->deleteToken($params->get('key'), $params->get('secret'));
     return $this;
 }
开发者ID:rohanabraham,项目名称:lxHive,代码行数:9,代码来源:Basic.php

示例10: function

// Database layer setup
$app->hook('slim.before', function () use($app) {
    $app->container->singleton('mongo', function () use($app) {
        $client = new Client($app->config('database')['host_uri']);
        $client->map([$app->config('database')['db_name'] => '\\API\\Collection']);
        $client->useDatabase($app->config('database')['db_name']);
        return $client;
    });
});
// CORS compatibility layer (Internet Explorer)
$app->hook('slim.before.router', function () use($app) {
    if ($app->request->isPost() && $app->request->get('method')) {
        $method = $app->request->get('method');
        $app->environment()['REQUEST_METHOD'] = strtoupper($method);
        mb_parse_str($app->request->getBody(), $postData);
        $parameters = new Set($postData);
        if ($parameters->has('content')) {
            $content = $parameters->get('content');
            $app->environment()['slim.input'] = $content;
            $parameters->remove('content');
        } else {
            // Content is the only valid body parameter...everything else are either headers or query parameters
            $app->environment()['slim.input'] = '';
        }
        $app->request->headers->replace($parameters->all());
        $app->environment()['slim.request.query_hash'] = $parameters->all();
    }
});
// Parse version
$app->hook('slim.before.dispatch', function () use($app) {
    // Version
开发者ID:rohanabraham,项目名称:lxHive,代码行数:31,代码来源:index.php

示例11: init

 /**
  * @param Set $container
  */
 public function init(Set $container)
 {
     $this->add($container->get('slim.middleware.request_logging'));
     $this->add($container->get('slim.middleware.store_events'));
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:8,代码来源:Middleware.php

示例12: init

 public function init(Set $container)
 {
     $this->add(new FakeMiddleware($container->get('logger')));
 }
开发者ID:comphppuebla,项目名称:slim-modules,代码行数:4,代码来源:MiddlewareLayersTest.php

示例13: renderGet

 public function renderGet()
 {
     $agent = new Set($this->agent);
     $object = ['objectType' => 'Person'];
     if ($agent->has('name')) {
         $object['name'] = [$agent->get('name')];
     }
     if ($agent->has('mbox')) {
         $object['mbox'] = [$agent->get('mbox')];
     }
     if ($agent->has('mbox_sha1sum')) {
         $object['mbox_sha1sum'] = [$agent->get('mbox_sha1sum')];
     }
     if ($agent->has('openid')) {
         $object['openid'] = [$agent->get('openid')];
     }
     if ($agent->has('account')) {
         $object['account'] = [$agent->get('account')];
     }
     return $object;
 }
开发者ID:rohanabraham,项目名称:lxHive,代码行数:21,代码来源:Agent.php

示例14: get

 /**
  * @param  string $key The data key
  * @param  mixed $default The value to return if data key does not exist
  * @return mixed           The data value, or the default value
  */
 public function get($key, $default = null)
 {
     if ($value = parent::get($key, $default)) {
         return $value;
     }
     return $this->pimple[$key];
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:12,代码来源:SlimContainer.php

示例15: set

 /**
  * @param string $key
  * @param Tag    $tag
  *
  * @throws InvalidTagException if the passed $value is not a Tag
  */
 public function set($key, $tag)
 {
     if ($tag instanceof Tag) {
         throw InvalidTagException::build([], ['invalidTag' => $tag]);
     }
     parent::set($key, $tag);
 }
开发者ID:cubicmushroom,项目名称:slim-service-manager,代码行数:13,代码来源:TagSet.php


注:本文中的Slim\Helper\Set类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。