本文整理汇总了PHP中Alchemy\Phrasea\Application类的典型用法代码示例。如果您正苦于以下问题:PHP Application类的具体用法?PHP Application怎么用?PHP Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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');
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}