本文整理汇总了PHP中Alchemy\Phrasea\Application::getApplicationBox方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getApplicationBox方法的具体用法?PHP Application::getApplicationBox怎么用?PHP Application::getApplicationBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alchemy\Phrasea\Application
的用法示例。
在下文中一共展示了Application::getApplicationBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: apply
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
$sql = "SHOW TABLE STATUS LIKE 'cache'";
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
$stmt->execute();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row['Auto_increment']) {
$sql = sprintf('ALTER TABLE Sessions AUTO_INCREMENT = %d', $row['Auto_increment']);
$app->getApplicationBox()->get_connection()->exec($sql);
}
return true;
}
示例5: updateRegistry
private function updateRegistry(Application $app)
{
$sql = 'SELECT `value` FROM registry WHERE `key` = :key';
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
$stmt->execute([':key' => 'GV_default_lng']);
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$locale = null !== $row ? $row['value'] : 'fr';
$sql = 'UPDATE registry SET `value` = :value WHERE `key` = :key';
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
$stmt->execute([':key' => 'GV_default_lng', ':value' => $this->extractLocale($locale)]);
$stmt->closeCursor();
}
示例6: 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();
}
示例7: 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;
}
示例8: set_order_master
/**
* Sets the user as "order_master" on a collection
*
* @param \collection $collection The collection to apply
* @param Boolean $bool Wheter the user is order master or not
*
* @return ACL
*/
public function set_order_master(\collection $collection, $bool)
{
$sql = 'UPDATE basusr SET order_master = :master
WHERE usr_id = :usr_id AND base_id = :base_id';
$stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql);
$stmt->execute([':master' => $bool ? 1 : 0, ':usr_id' => $this->user->getId(), ':base_id' => $collection->get_base_id()]);
$stmt->closeCursor();
return $this;
}
示例9: 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;
}
示例10: __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();
}
示例11: read
public function read(array $notifications, $usr_id)
{
if (count($notifications) == 0) {
return false;
}
/** @var Connection $connection */
$connection = $this->app->getApplicationBox()->get_connection();
$builder = $connection->createQueryBuilder();
$builder->update('notifications')->set('unread', '0')->where($builder->expr()->eq('usr_id', ':usr_id'), $builder->expr()->in('id', [':notifications']))->setParameters(['usr_id' => $usr_id, 'notifications' => $notifications], ['usr_id' => PDO::PARAM_INT, 'notifications' => Connection::PARAM_INT_ARRAY])->execute();
return $this;
}
示例12: goBackTo35
protected function goBackTo35()
{
$app = new Application(Application::ENV_TEST);
$conn = $app->getApplicationBox()->get_connection();
$this->uninstall();
file_put_contents(__DIR__ . '/../../../../../config/config.inc', "<?php\n\$servername = 'http://local.phrasea';\n");
file_put_contents(__DIR__ . '/../../../../../config/connexion.inc', "<?php\n\n\$hostname = '" . $conn->getHost() . "';\n\$port = '" . $conn->getPort() . "';\n\$user = '" . $conn->getUsername() . "';\n\$password = '" . $conn->getPassword() . "';\n\$dbname = '" . $conn->getDatabase() . "';\n ");
$this->tearDownHandlers[] = function () {
@unlink(__DIR__ . '/../../../../../config/config.inc');
@unlink(__DIR__ . '/../../../../../config/connexion.inc');
};
}
示例13: getInstance
/**
* Returns l'objet stockee dans le cache si i l existe sinon instancie
* un nouveau objet dashboard_feed
*
* @param Application $app
* @param integer $sbasid
* @param string $sbas_coll
* @param mixed $dmin
* @param mixed $dmax
*/
public static function getInstance(Application $app, $sbasid, $sbas_coll, $dmin, $dmax)
{
$cache_id = 'feed_' . md5($sbasid . '_' . $sbas_coll . '_' . $dmin . '_' . $dmax);
try {
$result = $app->getApplicationBox()->get_data_from_cache($cache_id);
$result->setApplication($app);
return $result;
} catch (\Exception $e) {
}
$tmp = new self($app, $sbasid, $sbas_coll, $dmin, $dmax);
$app->getApplicationBox()->set_data_to_cache($tmp, $cache_id);
return $tmp;
}
示例14: apply
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
$sql = 'SELECT * FROM registry
WHERE `key` = :key';
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
$Regbinaries = ['GV_cli', 'GV_swf_extract', 'GV_pdf2swf', 'GV_swf_render', 'GV_unoconv', 'GV_ffmpeg', 'GV_ffprobe', 'GV_mp4box', 'GV_pdftotext'];
$mapping = ['GV_cli' => 'php_binary', 'GV_swf_extract' => 'swf_extract_binary', 'GV_pdf2swf' => 'pdf2swf_binary', 'GV_swf_render' => 'swf_render_binary', 'GV_unoconv' => 'unoconv_binary', 'GV_ffmpeg' => 'ffmpeg_binary', 'GV_ffprobe' => 'ffprobe_binary', 'GV_mp4box' => 'mp4box_binary', 'GV_pdftotext' => 'pdftotext_binary'];
$binaries = ['ghostscript_binary' => null];
foreach ($Regbinaries as $name) {
$stmt->execute([':key' => $name]);
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$value = is_executable($row['value']) ? $row['value'] : null;
$binaries[$mapping[$name]] = $value;
}
$stmt->closeCursor();
$config = $app['configuration.store']->getConfig();
$config['binaries'] = $binaries;
$sql = 'DELETE FROM registry WHERE `key` = :key';
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
foreach ($Regbinaries as $name) {
$stmt->execute([':key' => $name]);
}
$stmt->closeCursor();
$sql = 'SELECT value FROM registry WHERE `key` = :key';
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
$stmt->execute([':key' => 'GV_sit']);
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$config['main']['key'] = $row['value'];
$app['configuration.store']->setConfig($config);
$sql = 'DELETE FROM registry WHERE `key` = :key';
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
$stmt->execute([':key' => 'GV_sit']);
$stmt->closeCursor();
return true;
}
示例15: apply
/**
* {@inheritdoc}
*/
public function apply(base $databox, Application $app)
{
$sql = 'TRUNCATE metadatas';
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'TRUNCATE metadatas_structure';
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'TRUNCATE technical_datas';
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$phrasea_maps = ['pdftext' => 'Phraseanet:pdftext', 'tf-archivedate' => 'Phraseanet:tf-archivedate', 'tf-atime' => 'Phraseanet:tf-atime', 'tf-chgdocdate' => 'Phraseanet:tf-chgdocdate', 'tf-ctime' => 'Phraseanet:tf-ctime', 'tf-editdate' => 'Phraseanet:tf-editdate', 'tf-mtime' => 'Phraseanet:tf-mtime', 'tf-parentdir' => 'Phraseanet:tf-parentdir', 'tf-bits' => 'Phraseanet:tf-bits', 'tf-channels' => 'Phraseanet:tf-channels', 'tf-extension' => 'Phraseanet:tf-extension', 'tf-filename' => 'Phraseanet:tf-filename', 'tf-filepath' => 'Phraseanet:tf-filepath', 'tf-height' => 'Phraseanet:tf-height', 'tf-mimetype' => 'Phraseanet:tf-mimetype', 'tf-recordid' => 'Phraseanet:tf-recordid', 'tf-size' => 'Phraseanet:tf-size', 'tf-width' => 'Phraseanet:tf-width'];
$sxe = $databox->get_sxml_structure();
$dom_struct = $databox->get_dom_structure();
$xp_struct = $databox->get_xpath_structure();
foreach ($sxe->description->children() as $fname => $field) {
$src = trim(isset($field['src']) ? $field['src'] : '');
if (array_key_exists($src, $phrasea_maps)) {
$src = $phrasea_maps[$src];
}
$nodes = $xp_struct->query('/record/description/' . $fname);
if ($nodes->length > 0) {
$node = $nodes->item(0);
$node->setAttribute('src', $src);
$node->removeAttribute('meta_id');
}
}
$databox->saveStructure($dom_struct);
$databox->feed_meta_fields();
$databox->delete_data_from_cache(databox::CACHE_STRUCTURE);
$databox->delete_data_from_cache(databox::CACHE_META_STRUCT);
$conn = $app->getApplicationBox()->get_connection();
$sql = 'DELETE FROM `task2` WHERE class="readmeta"';
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
unset($stmt);
return true;
}