• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Phrasea\Application类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $conn = $app->getApplicationBox()->get_connection();
     $sql = 'SELECT date, login, ip, locked
             FROM badlog
             ORDER BY id ASC';
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $n = 1;
     foreach ($rs as $row) {
         $date = Datetime::createFromFormat('Y-m-d h:i:s', $row['date']);
         $failure = new AuthFailure();
         if ($date) {
             $failure->setCreated($date);
         }
         $failure->setIp($row['ip']);
         $failure->setLocked(!!$row['locked']);
         $failure->setUsername($row['login']);
         $app['orm.em']->persist($failure);
         if (0 === $n++ % 1000) {
             $app['orm.em']->flush();
             $app['orm.em']->clear();
         }
     }
     $app['orm.em']->flush();
     $app['orm.em']->clear();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:33,代码来源:380alpha4a.php


示例2: create

 /**
  * Creates an account
  *
  * @param Application $app       The application
  * @param string      $id        The base for user login
  * @param string      $email     The email
  * @param array       $templates Some extra templates to apply with the ones of this creator
  *
  * @return User
  *
  * @throws RuntimeException         In case the AccountCreator is disabled
  * @throws InvalidArgumentException In case a user with the same email already exists
  */
 public function create(Application $app, $id, $email = null, array $templates = [])
 {
     if (!$this->enabled) {
         throw new RuntimeException('Account creator is disabled');
     }
     $login = $id;
     $n = 1;
     if (null !== $email && null !== $app['repo.users']->findByEmail($email)) {
         throw new InvalidArgumentException('Provided email already exist in account base.');
     }
     while (null !== $app['repo.users']->findByLogin($login)) {
         $login = $id . '#' . $n;
         $n++;
     }
     $user = $app['manipulator.user']->createUser($login, $this->random->generateString(128), $email);
     $base_ids = [];
     foreach ($this->appbox->get_databoxes() as $databox) {
         foreach ($databox->get_collections() as $collection) {
             $base_ids[] = $collection->get_base_id();
         }
     }
     foreach (array_merge($this->templates, $templates) as $template) {
         $app->getAclForUser($user)->apply_model($template, $base_ids);
     }
     return $user;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:39,代码来源:AccountCreator.php


示例3: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'DELETE FROM Tasks';
     $stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $sql = 'SELECT task_id, active, crashed, name, class, settings FROM task2';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     foreach ($rs as $row) {
         try {
             $job = $this->createJob($app, $row['class']);
         } catch (\RuntimeException $e) {
             continue;
         }
         $settings = simplexml_load_string($row['settings']);
         $period = $job->getEditor()->getDefaultPeriod();
         if ($settings->period) {
             $period = (int) $settings->period;
             unset($settings->period);
             $row['settings'] = $settings->asXML();
         }
         $task = new Task();
         $task->setCrashed($row['crashed'])->setJobId($job->getJobId())->setName($row['name'])->setPeriod($period)->setSettings($row['settings'])->setStatus($row['active'] ? Task::STATUS_STARTED : Task::STATUS_STOPPED);
         $app['orm.em']->persist($task);
     }
     $app['orm.em']->flush();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:33,代码来源:390alpha8a.php


示例4: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'DELETE FROM UserNotificationSettings';
     $stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $conn = $app->getApplicationBox()->get_connection();
     $sql = 'SELECT * FROM usr_settings
             WHERE prop LIKE "notification_%"';
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $n = 0;
     $em = $app['orm.em'];
     foreach ($rs as $row) {
         if (null === ($user = $this->loadUser($app['orm.em'], $row['usr_id']))) {
             continue;
         }
         $userSetting = new UserNotificationSetting();
         $userSetting->setName($row['prop']);
         $userSetting->setValue($row['value']);
         $userSetting->setUser($user);
         $em->persist($userSetting);
         $n++;
         if ($n % 200 === 0) {
             $em->flush();
             $em->clear();
         }
     }
     $em->flush();
     $em->clear();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:37,代码来源:390alpha5a.php


示例5: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'DELETE FROM UserQueries';
     $stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $conn = $app->getApplicationBox()->get_connection();
     $sql = 'SELECT * FROM dsel';
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $n = 0;
     $em = $app['orm.em'];
     foreach ($rs as $row) {
         if (null === ($user = $this->loadUser($app['orm.em'], $row['usr_id']))) {
             continue;
         }
         $userQuery = new UserQuery();
         $userQuery->setQuery($row['query']);
         $userQuery->setUser($user);
         $em->persist($userQuery);
         $n++;
         if ($n % 1000 === 0) {
             $em->flush();
             $em->clear();
         }
     }
     $em->flush();
     $em->clear();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:35,代码来源:390alpha3a.php


示例6: getUnvalidated

 private static function getUnvalidated(Application $app, $home = false)
 {
     $terms = [];
     foreach ($app->getDataboxes() as $databox) {
         try {
             $cgus = $databox->get_cgus();
             if (!isset($cgus[$app['locale']])) {
                 throw new Exception('No CGus for this locale');
             }
             $name = $databox->get_label($app['locale']);
             $update = $cgus[$app['locale']]['updated_on'];
             $value = $cgus[$app['locale']]['value'];
             $userValidation = true;
             if (!$home) {
                 if (!$app->getAclForUser($app->getAuthenticatedUser())->has_access_to_sbas($databox->get_sbas_id())) {
                     continue;
                 }
                 $userValidation = $app['settings']->getUserSetting($app->getAuthenticatedUser(), 'terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== '';
             }
             if ($userValidation) {
                 $terms[$name] = ['sbas_id' => $databox->get_sbas_id(), 'terms' => $value, 'date' => $update];
             }
         } catch (\Exception $e) {
         }
     }
     return $terms;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:27,代码来源:cgu.php


示例7: testInstall

 /**
  * @covers Alchemy\Phrasea\Setup\Installer
  */
 public function testInstall()
 {
     $app = new Application('test');
     $app->bindRoutes();
     $parser = new Parser();
     $connDatas = $parser->parse(file_get_contents(__DIR__ . '/../../../../../config/configuration.yml'));
     $credentials = $connDatas['main']['database'];
     $config = __DIR__ . '/configuration.yml';
     $compiled = __DIR__ . '/configuration.yml.php';
     @unlink($config);
     @unlink($compiled);
     $app['configuration.store'] = new Configuration(new Yaml(), new Compiler(), $config, $compiled, true);
     $abConn = self::$DI['app']['dbal.provider']->get(['host' => 'localhost', 'port' => 3306, 'user' => $credentials['user'], 'password' => $credentials['password'], 'dbname' => 'ab_unitTests']);
     $abConn->connect();
     $dbConn = self::$DI['app']['dbal.provider']->get(['host' => 'localhost', 'port' => 3306, 'user' => $credentials['user'], 'password' => $credentials['password'], 'dbname' => 'db_unitTests']);
     $dbConn->connect();
     $template = 'en';
     $dataPath = __DIR__ . '/../../../../../datas/';
     $installer = new Installer($app);
     $installer->install(uniqid('admin') . '@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', $dataPath, $dbConn, $template);
     $this->assertTrue($app['configuration.store']->isSetup());
     $this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
     $databoxes = $app['phraseanet.appbox']->get_databoxes();
     $databox = array_pop($databoxes);
     $this->assertContains('<path>' . realpath($dataPath) . '/db_unitTests/subdefs</path>', $databox->get_structure());
     $conf = $app['configuration.store']->getConfig();
     $this->assertArrayHasKey('main', $conf);
     $this->assertArrayHasKey('key', $conf['main']);
     $this->assertGreaterThan(10, strlen($conf['main']['key']));
     @unlink($config);
     @unlink($compiled);
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:35,代码来源:InstallerTest.php


示例8: createFromUser

 /**
  * Creates an aggregate from all the feeds available to a given user.
  *
  * @param Application $app
  * @param User        $user
  *
  * @param array       $restrictions
  * @return Aggregate
  */
 public static function createFromUser(Application $app, User $user, array $restrictions = [])
 {
     /** @var FeedRepository $feedRepository */
     $feedRepository = $app['repo.feeds'];
     $feeds = $feedRepository->filterUserAccessibleByIds($app->getAclForUser($user), $restrictions);
     $token = $app['repo.aggregate-tokens']->findOneBy(['user' => $user]);
     return new static($app['orm.em'], $feeds, $token);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:17,代码来源:Aggregate.php


示例9: post

 /**
  * {@inheritdoc}
  */
 public function post(Application $app, Request $request)
 {
     $configuration = $this->getConfiguration();
     $configuration['host'] = $request->request->get('host');
     $configuration['port'] = $request->request->get('port');
     $this->saveConfiguration($configuration);
     return $app->redirectPath('admin_searchengine_get');
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:11,代码来源:ConfigurationPanel.php


示例10: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $app['conf']->remove(['main', 'api-timers']);
     if ($this->tableHasField($app['orm.em'], 'api_logs', 'api_log_ressource')) {
         $sql = "ALTER TABLE api_logs CHANGE api_log_ressource api_log_resource varchar(64)";
         $app->getApplicationBox()->get_connection()->executeUpdate($sql);
     }
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:12,代码来源:390alpha14a.php


示例11: __construct

 public function __construct(Application $app, module_report $report)
 {
     $this->conn = $app->getApplicationBox()->get_connection();
     $this->connbas = $app->findDataboxById($report->getSbasId())->get_connection();
     $this->filter = new module_report_sqlfilter($app, $report);
     $this->sql = '';
     $this->params = [];
     $this->total_row = 0;
     $this->enable_limit = $report->getEnableLimit();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:10,代码来源:sql.php


示例12: __construct

 public function __construct(Application $app, module_report $report)
 {
     $this->app = $app;
     $this->conn = $app->findDataboxById($report->getSbasId())->get_connection();
     if (is_array($report->getTransQueryString())) {
         $this->cor_query = $report->getTransQueryString();
     }
     $this->buildFilter($report);
     $this->report = $report;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:10,代码来源:sqlfilter.php


示例13: setUp

 protected function setUp()
 {
     $this->appbox = $this->getMockBuilder(\appbox::class)->disableOriginalConstructor()->getMock();
     $this->twig = $this->getMockBuilder(\Twig_Environment::class)->disableOriginalConstructor()->getMock();
     $this->aclProvider = $this->getMockBuilder(ACLProvider::class)->disableOriginalConstructor()->getMock();
     $this->authenticator = $this->getMockBuilder(Authenticator::class)->disableOriginalConstructor()->getMock();
     $this->app = $this->getMockBuilder(Application::class)->disableOriginalConstructor()->getMock();
     $this->app->expects($this->any())->method('offsetGet')->willReturnMap([['phraseanet.appbox', $this->appbox], ['twig', $this->twig], ['authentication', $this->authenticator], ['acl', $this->aclProvider]]);
     $this->sut = new Controller($this->app);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:10,代码来源:ControllerTest.php


示例14: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'DELETE FROM FtpExports';
     $stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $sql = 'DELETE FROM FtpExportElements';
     $stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $conn = $app->getApplicationBox()->get_connection();
     $em = $app['orm.em'];
     $em->getEventManager()->removeEventSubscriber(new TimestampableListener());
     $sql = 'SELECT `id`, `crash`, `nbretry`, `mail`, `addr`, `ssl`,
                 `login`, `pwd`, `passif`,
                 `destfolder`, `sendermail`, `text_mail_sender`,
                 `text_mail_receiver`, `usr_id`, `date`, `foldertocreate`,
                 `logfile`
             FROM ftp_export';
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $sql = 'SELECT base_id, record_id, subdef, filename, folder, error, done, businessfields
             FROM ftp_export_elements
             WHERE ftp_export_id = :export_id';
     $stmt = $conn->prepare($sql);
     $n = 0;
     foreach ($rs as $row) {
         if (null === ($user = $this->loadUser($app['orm.em'], $row['usr_id']))) {
             continue;
         }
         $export = new FtpExport();
         $export->setAddr($row['addr'])->setCrash($row['crash'])->setNbretry($row['nbretry'])->setMail($row['mail'])->setSsl($row['ssl'])->setLogin($row['login'])->setPwd($row['pwd'])->setPassif($row['passif'])->setDestfolder($row['destfolder'])->setSendermail($row['sendermail'])->setTextMailReceiver($row['text_mail_sender'])->setTextMailSender($row['text_mail_reveiver'])->setUser($user)->setCreated(new \DateTime($row['date']))->setUpdated(new \DateTime($row['date']))->setFoldertocreate($row['foldertocreate'])->setLogfile($row['logfile']);
         $em->persist($export);
         $stmt->execute(['export_id' => $row['id']]);
         $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
         foreach ($rs as $element) {
             $element = new FtpExportElement();
             $element->setBaseId($row['base_id'])->setRecordId($row['record_id'])->setBusinessfields($row['businessfields'])->setCreated(new \DateTime($row['date']))->setUpdated(new \DateTime($row['date']))->setDone(!!$row['done'])->setError(!!$row['error'])->setFilename($row['filename'])->setFolder($row['folder'])->setSubdef($row['subdef'])->setExport($export);
             $export->addElement($element);
             $em->persist($element);
         }
         $n++;
         if ($n % 200 === 0) {
             $em->flush();
             $em->clear();
         }
     }
     $stmt->closeCursor();
     $em->flush();
     $em->clear();
     $em->getEventManager()->addEventSubscriber(new TimestampableListener());
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:58,代码来源:390alpha6a.php


示例15: request

 private function request($accept)
 {
     $app = new Application(Application::ENV_TEST);
     $app['dispatcher']->addSubscriber(new ContentNegotiationSubscriber($app['negotiator'], $app['phraseanet.content-negotiation.priorities']));
     $app->get('/content/negociation', function () {
         return '';
     });
     $client = new Client($app);
     $client->request('GET', '/content/negociation', array(), array(), array('HTTP_Accept' => $accept));
     return $client->getResponse();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:11,代码来源:ContentNegotiationSubscriberTest.php


示例16: testError

 /**
  * @dataProvider provideExceptionsAndCode
  */
 public function testError($exception, $code)
 {
     $app = new Application('test');
     $app['dispatcher']->addSubscriber(new ApiExceptionHandlerSubscriber($app));
     $app->get('/', function () use($exception) {
         throw $exception;
     });
     $client = new Client($app);
     $client->request('GET', '/');
     $this->assertEquals($code, $client->getResponse()->getStatusCode());
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:14,代码来源:ApiExceptionHandlerSubscriberTest.php


示例17: request

 private function request($accept)
 {
     $app = new Application('test');
     $app['dispatcher']->addSubscriber(new ContentNegotiationSubscriber($app));
     $app->get('/content/negociation', function () {
         return '';
     });
     $client = new Client($app);
     $client->request('GET', '/content/negociation', array(), array(), array('HTTP_Accept' => $accept));
     return $client->getResponse();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:11,代码来源:ContentNegotiationSubscriberTest.php


示例18: testNoHeaderNoRedirection

 public function testNoHeaderNoRedirection()
 {
     $app = new Application();
     unset($app['exception_handler']);
     $app['dispatcher']->addSubscriber(new FirewallSubscriber());
     $app->get('/', function () {
         throw new HttpException(500);
     });
     $client = new Client($app);
     $this->setExpectedException('Symfony\\Component\\HttpKernel\\Exception\\HttpException');
     $client->request('GET', '/');
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:12,代码来源:FirewallSubscriberTest.php


示例19: getGlobals

 public function getGlobals(Application $app, Request $request)
 {
     $form = $app['registry.manipulator']->createForm($app['conf']);
     if ('POST' === $request->getMethod()) {
         $form->bind($request);
         if ($form->isValid()) {
             $app['conf']->set('registry', $app['registry.manipulator']->getRegistryData($form));
             return $app->redirectPath('setup_display_globals');
         }
     }
     return $app['twig']->render('admin/setup.html.twig', ['form' => $form->createView()]);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:12,代码来源:Setup.php


示例20: request

 /**
  * @param array  $conf
  * @param string $method
  * @param array  $extraHeaders
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 private function request(array $conf, $method = 'GET', array $extraHeaders = [])
 {
     $app = new Application('test');
     $app['phraseanet.configuration']['api_cors'] = $conf;
     $app['dispatcher']->addSubscriber(new ApiCorsSubscriber($app));
     $app->get('/api/v1/test-route', function () {
         return '';
     });
     $client = new Client($app);
     $client->request($method, '/api/v1/test-route', [], [], array_merge($extraHeaders, ['HTTP_Origin' => $this->origin]));
     return $client->getResponse();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:19,代码来源:ApiCorsSubscriberTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Command\Command类代码示例发布时间:2022-05-23
下一篇:
PHP Model\Album类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap