repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Entities/Feed.php
Feed.getPublisher
public function getPublisher(User $user) { foreach ($this->getPublishers() as $publisher) { if ($publisher->getUser()->getId() == $user->getId()) { return $publisher; } } return null; }
php
public function getPublisher(User $user) { foreach ($this->getPublishers() as $publisher) { if ($publisher->getUser()->getId() == $user->getId()) { return $publisher; } } return null; }
[ "public", "function", "getPublisher", "(", "User", "$", "user", ")", "{", "foreach", "(", "$", "this", "->", "getPublishers", "(", ")", "as", "$", "publisher", ")", "{", "if", "(", "$", "publisher", "->", "getUser", "(", ")", "->", "getId", "(", ")",...
Returns an instance of FeedPublisher matching to the given user. @param User $user @return FeedPublisher
[ "Returns", "an", "instance", "of", "FeedPublisher", "matching", "to", "the", "given", "user", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/Feed.php#L397-L406
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Entities/Feed.php
Feed.hasAccess
public function hasAccess(User $user, Application $app) { if ($this->getCollection($app) instanceof collection) { return $app->getAclForUser($user)->has_access_to_base($this->collection->get_base_id()); } return true; }
php
public function hasAccess(User $user, Application $app) { if ($this->getCollection($app) instanceof collection) { return $app->getAclForUser($user)->has_access_to_base($this->collection->get_base_id()); } return true; }
[ "public", "function", "hasAccess", "(", "User", "$", "user", ",", "Application", "$", "app", ")", "{", "if", "(", "$", "this", "->", "getCollection", "(", "$", "app", ")", "instanceof", "collection", ")", "{", "return", "$", "app", "->", "getAclForUser",...
Returns a boolean indicating whether the given user has access to the feed. @param User $user @param Application $app @return boolean
[ "Returns", "a", "boolean", "indicating", "whether", "the", "given", "user", "has", "access", "to", "the", "feed", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/Feed.php#L459-L466
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordQueuer.php
RecordQueuer.didStartIndexingRecords
public static function didStartIndexingRecords(array $records, databox $databox) { $connection = $databox->get_connection(); $sql = "UPDATE record SET jeton = (jeton | :flag) WHERE record_id IN (:record_ids)"; self::executeFlagQuery($connection, $sql, Flag::INDEXING, $records); }
php
public static function didStartIndexingRecords(array $records, databox $databox) { $connection = $databox->get_connection(); $sql = "UPDATE record SET jeton = (jeton | :flag) WHERE record_id IN (:record_ids)"; self::executeFlagQuery($connection, $sql, Flag::INDEXING, $records); }
[ "public", "static", "function", "didStartIndexingRecords", "(", "array", "$", "records", ",", "databox", "$", "databox", ")", "{", "$", "connection", "=", "$", "databox", "->", "get_connection", "(", ")", ";", "$", "sql", "=", "\"UPDATE record SET jeton = (jeton...
@param array $records @param databox $databox nb: changing the jeton may affect a fetcher if his "where" clause (delegate) depends on jeton. in this case the client of the fetcher must set a "postFetch" callback and restart the fetcher
[ "@param", "array", "$records", "@param", "databox", "$databox" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordQueuer.php#L53-L59
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordQueuer.php
RecordQueuer.didFinishIndexingRecords
public static function didFinishIndexingRecords(array $records, databox $databox) { $connection = $databox->get_connection(); $sql = "UPDATE record SET jeton = (jeton & ~ :flag) WHERE record_id IN (:record_ids)"; self::executeFlagQuery($connection, $sql, Flag::TO_INDEX | Flag::INDEXING, $records); }
php
public static function didFinishIndexingRecords(array $records, databox $databox) { $connection = $databox->get_connection(); $sql = "UPDATE record SET jeton = (jeton & ~ :flag) WHERE record_id IN (:record_ids)"; self::executeFlagQuery($connection, $sql, Flag::TO_INDEX | Flag::INDEXING, $records); }
[ "public", "static", "function", "didFinishIndexingRecords", "(", "array", "$", "records", ",", "databox", "$", "databox", ")", "{", "$", "connection", "=", "$", "databox", "->", "get_connection", "(", ")", ";", "$", "sql", "=", "\"UPDATE record SET jeton = (jeto...
@param array $records @param $databox nb: changing the jeton may affect a fetcher if his "where" clause (delegate) depends on jeton. in this case the client of the fetcher must set a "postFetch" callback and restart the fetcher
[ "@param", "array", "$records", "@param", "$databox" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordQueuer.php#L68-L73
alchemy-fr/Phraseanet
lib/classes/patch/390alpha16a.php
patch_390alpha16a.apply
public function apply(base $appbox, Application $app) { $sql = ' SELECT edit_preset_id, creation_date, title, xml, usr_id, sbas_id FROM edit_presets'; $em = $app['orm.em']; $n = 0; $em->getEventManager()->removeEventSubscriber(new TimestampableListener()); foreach ($app->getApplicationBox()->get_connection()->fetchAll($sql) as $row) { if (null === $user = $this->loadUser($app['orm.em'], $row['usr_id'])) { continue; } $preset = new Preset(); $preset->setUser($user); $preset->setSbasId($row['sbas_id']); $preset->setTitle($row['title']); $fields = []; if (false !== ($sx = @simplexml_load_string($row['xml']))) { if (false === isset($sx->fields)) { continue; } foreach ($sx->fields->children() as $name => $value) { $fields[] = ['name' => $name, 'value' => $value]; } } $preset->setData($fields); $em->persist($preset); $n++; if ($n % 20 === 0) { $em->flush(); $em->clear(); } } $em->flush(); $em->clear(); $em->getEventManager()->addEventSubscriber(new TimestampableListener()); return true; }
php
public function apply(base $appbox, Application $app) { $sql = ' SELECT edit_preset_id, creation_date, title, xml, usr_id, sbas_id FROM edit_presets'; $em = $app['orm.em']; $n = 0; $em->getEventManager()->removeEventSubscriber(new TimestampableListener()); foreach ($app->getApplicationBox()->get_connection()->fetchAll($sql) as $row) { if (null === $user = $this->loadUser($app['orm.em'], $row['usr_id'])) { continue; } $preset = new Preset(); $preset->setUser($user); $preset->setSbasId($row['sbas_id']); $preset->setTitle($row['title']); $fields = []; if (false !== ($sx = @simplexml_load_string($row['xml']))) { if (false === isset($sx->fields)) { continue; } foreach ($sx->fields->children() as $name => $value) { $fields[] = ['name' => $name, 'value' => $value]; } } $preset->setData($fields); $em->persist($preset); $n++; if ($n % 20 === 0) { $em->flush(); $em->clear(); } } $em->flush(); $em->clear(); $em->getEventManager()->addEventSubscriber(new TimestampableListener()); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "sql", "=", "' SELECT edit_preset_id, creation_date, title, xml, usr_id, sbas_id\n FROM edit_presets'", ";", "$", "em", "=", "$", "app", "[", "'or...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/390alpha16a.php#L59-L101
alchemy-fr/Phraseanet
lib/classes/module/report/dashboard/merge.php
module_report_dashboard_merge.toString
private function toString() { foreach ($this->sorted[$this->currentkey] as $k => $v) $this->sorted[$this->currentkey][$k] = (string) number_format($v, 2, '.', ''); return; }
php
private function toString() { foreach ($this->sorted[$this->currentkey] as $k => $v) $this->sorted[$this->currentkey][$k] = (string) number_format($v, 2, '.', ''); return; }
[ "private", "function", "toString", "(", ")", "{", "foreach", "(", "$", "this", "->", "sorted", "[", "$", "this", "->", "currentkey", "]", "as", "$", "k", "=>", "$", "v", ")", "$", "this", "->", "sorted", "[", "$", "this", "->", "currentkey", "]", ...
@desc force value to string values this is the format to respect for displaying float results in SVG google charts @return void;
[ "@desc", "force", "value", "to", "string", "values", "this", "is", "the", "format", "to", "respect", "for", "displaying", "float", "results", "in", "SVG", "google", "charts" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report/dashboard/merge.php#L160-L167
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php
TaskManipulator.create
public function create($name, $jobId, $settings, $period) { $task = new Task(); $task->setName($name) ->setJobId($jobId) ->setSettings($settings) ->setPeriod($period); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_CREATE); return $task; }
php
public function create($name, $jobId, $settings, $period) { $task = new Task(); $task->setName($name) ->setJobId($jobId) ->setSettings($settings) ->setPeriod($period); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_CREATE); return $task; }
[ "public", "function", "create", "(", "$", "name", ",", "$", "jobId", ",", "$", "settings", ",", "$", "period", ")", "{", "$", "task", "=", "new", "Task", "(", ")", ";", "$", "task", "->", "setName", "(", "$", "name", ")", "->", "setJobId", "(", ...
Creates a Task. @param string $name @param string $jobId @param string $settings @param integer $period @return Task
[ "Creates", "a", "Task", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php#L54-L68
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php
TaskManipulator.createEmptyCollectionJob
public function createEmptyCollectionJob(\collection $collection) { $job = new EmptyCollectionJob($this->translator); $settings = simplexml_load_string($job->getEditor()->getDefaultSettings()); $settings->bas_id = $collection->get_base_id(); $task = new Task(); $task->setName($job->getName()) ->setJobId($job->getJobId()) ->setSettings($settings->asXML()) ->setPeriod($job->getEditor()->getDefaultPeriod()); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_CREATE); return $task; }
php
public function createEmptyCollectionJob(\collection $collection) { $job = new EmptyCollectionJob($this->translator); $settings = simplexml_load_string($job->getEditor()->getDefaultSettings()); $settings->bas_id = $collection->get_base_id(); $task = new Task(); $task->setName($job->getName()) ->setJobId($job->getJobId()) ->setSettings($settings->asXML()) ->setPeriod($job->getEditor()->getDefaultPeriod()); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_CREATE); return $task; }
[ "public", "function", "createEmptyCollectionJob", "(", "\\", "collection", "$", "collection", ")", "{", "$", "job", "=", "new", "EmptyCollectionJob", "(", "$", "this", "->", "translator", ")", ";", "$", "settings", "=", "simplexml_load_string", "(", "$", "job"...
Creates a EmptyCollection task given a collection @param \collection $collection @return Task
[ "Creates", "a", "EmptyCollection", "task", "given", "a", "collection" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php#L77-L95
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php
TaskManipulator.update
public function update(Task $task) { $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_UPDATE); return $task; }
php
public function update(Task $task) { $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_UPDATE); return $task; }
[ "public", "function", "update", "(", "Task", "$", "task", ")", "{", "$", "this", "->", "om", "->", "persist", "(", "$", "task", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "$", "this", "->", "notify", "(", "NotifierInterface", ...
Updates a Task in the manager. @param Task $task @return Task
[ "Updates", "a", "Task", "in", "the", "manager", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php#L104-L112
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php
TaskManipulator.delete
public function delete(Task $task) { $this->om->remove($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_DELETE); }
php
public function delete(Task $task) { $this->om->remove($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_DELETE); }
[ "public", "function", "delete", "(", "Task", "$", "task", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "task", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "$", "this", "->", "notify", "(", "NotifierInterface", ...
Deletes a task. @param Task $task
[ "Deletes", "a", "task", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php#L119-L125
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php
TaskManipulator.start
public function start(Task $task) { $task->setStatus(Task::STATUS_STARTED); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_UPDATE); return $task; }
php
public function start(Task $task) { $task->setStatus(Task::STATUS_STARTED); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_UPDATE); return $task; }
[ "public", "function", "start", "(", "Task", "$", "task", ")", "{", "$", "task", "->", "setStatus", "(", "Task", "::", "STATUS_STARTED", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "task", ")", ";", "$", "this", "->", "om", "->", ...
Sets the task status to "started". @param Task $task @return Task
[ "Sets", "the", "task", "status", "to", "started", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php#L134-L144
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php
TaskManipulator.stop
public function stop(Task $task) { $task->setStatus(Task::STATUS_STOPPED); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_UPDATE); return $task; }
php
public function stop(Task $task) { $task->setStatus(Task::STATUS_STOPPED); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_UPDATE); return $task; }
[ "public", "function", "stop", "(", "Task", "$", "task", ")", "{", "$", "task", "->", "setStatus", "(", "Task", "::", "STATUS_STOPPED", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "task", ")", ";", "$", "this", "->", "om", "->", ...
Sets the task status to "stopped". @param Task $task @return Task
[ "Sets", "the", "task", "status", "to", "stopped", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php#L153-L163
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php
TaskManipulator.resetCrashes
public function resetCrashes(Task $task) { $task->setCrashed(0); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_UPDATE); return $task; }
php
public function resetCrashes(Task $task) { $task->setCrashed(0); $this->om->persist($task); $this->om->flush(); $this->notify(NotifierInterface::MESSAGE_UPDATE); return $task; }
[ "public", "function", "resetCrashes", "(", "Task", "$", "task", ")", "{", "$", "task", "->", "setCrashed", "(", "0", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "task", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")",...
Reset the number of crashes of the task. @param Task $task @return Task
[ "Reset", "the", "number", "of", "crashes", "of", "the", "task", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/TaskManipulator.php#L172-L182
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/CLI.php
CLI.runCLI
public function runCLI($interactive = false) { $this->boot(); $app = $this['console']; if ($interactive) { $app = new Console\Shell($app); } $app->run(); }
php
public function runCLI($interactive = false) { $this->boot(); $app = $this['console']; if ($interactive) { $app = new Console\Shell($app); } $app->run(); }
[ "public", "function", "runCLI", "(", "$", "interactive", "=", "false", ")", "{", "$", "this", "->", "boot", "(", ")", ";", "$", "app", "=", "$", "this", "[", "'console'", "]", ";", "if", "(", "$", "interactive", ")", "{", "$", "app", "=", "new", ...
Executes this application. @param bool $interactive runs in an interactive shell if true.
[ "Executes", "this", "application", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/CLI.php#L90-L101
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/CLI.php
CLI.command
public function command($command) { if ($command instanceof CommandInterface) { $command->setContainer($this); } $this['console']->add($command); }
php
public function command($command) { if ($command instanceof CommandInterface) { $command->setContainer($this); } $this['console']->add($command); }
[ "public", "function", "command", "(", "$", "command", ")", "{", "if", "(", "$", "command", "instanceof", "CommandInterface", ")", "{", "$", "command", "->", "setContainer", "(", "$", "this", ")", ";", "}", "$", "this", "[", "'console'", "]", "->", "add...
Adds a command object. If a command with the same name already exists, it will be overridden. @param Command|CommandInterface $command A Command object
[ "Adds", "a", "command", "object", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/CLI.php#L126-L133
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Provider/FileServeServiceProvider.php
FileServeServiceProvider.register
public function register(Application $app) { $app['phraseanet.xsendfile-factory'] = $app->share(function ($app) { return XSendFileFactory::create($app); }); $app['phraseanet.h264-factory'] = $app->share(function ($app) { return H264Factory::create($app); }); $app['phraseanet.h264'] = $app->share(function ($app) { return $app['phraseanet.h264-factory']->createMode(false); }); $app['phraseanet.static-file'] = $app->share(function (Application $app) { return new StaticMode($app['phraseanet.thumb-symlinker']); }); $app['phraseanet.file-serve'] = $app->share(function (Application $app) { return new ServeFileResponseFactory($app['unicode']); }); }
php
public function register(Application $app) { $app['phraseanet.xsendfile-factory'] = $app->share(function ($app) { return XSendFileFactory::create($app); }); $app['phraseanet.h264-factory'] = $app->share(function ($app) { return H264Factory::create($app); }); $app['phraseanet.h264'] = $app->share(function ($app) { return $app['phraseanet.h264-factory']->createMode(false); }); $app['phraseanet.static-file'] = $app->share(function (Application $app) { return new StaticMode($app['phraseanet.thumb-symlinker']); }); $app['phraseanet.file-serve'] = $app->share(function (Application $app) { return new ServeFileResponseFactory($app['unicode']); }); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'phraseanet.xsendfile-factory'", "]", "=", "$", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "return", "XSendFileFactory", "::", "create", "(...
{@inheritDoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Provider/FileServeServiceProvider.php#L28-L49
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Provider/FileServeServiceProvider.php
FileServeServiceProvider.boot
public function boot(Application $app) { $app['dispatcher'] = $app->share( $app->extend('dispatcher', function (EventDispatcherInterface $dispatcher, Application $app) { $dispatcher->addSubscriber(new XSendFileSubscriber($app)); return $dispatcher; }) ); }
php
public function boot(Application $app) { $app['dispatcher'] = $app->share( $app->extend('dispatcher', function (EventDispatcherInterface $dispatcher, Application $app) { $dispatcher->addSubscriber(new XSendFileSubscriber($app)); return $dispatcher; }) ); }
[ "public", "function", "boot", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'dispatcher'", "]", "=", "$", "app", "->", "share", "(", "$", "app", "->", "extend", "(", "'dispatcher'", ",", "function", "(", "EventDispatcherInterface", "$", "di...
{@inheritDoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Provider/FileServeServiceProvider.php#L54-L63
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php
MailInfoPushReceived.getSubject
public function getSubject() { if (!$this->basket) { throw new LogicException('You must set a basket before calling getSubject'); } return $this->app->trans('Reception of %basket_name%', ['%basket_name%' => $this->basket->getName()]); }
php
public function getSubject() { if (!$this->basket) { throw new LogicException('You must set a basket before calling getSubject'); } return $this->app->trans('Reception of %basket_name%', ['%basket_name%' => $this->basket->getName()]); }
[ "public", "function", "getSubject", "(", ")", "{", "if", "(", "!", "$", "this", "->", "basket", ")", "{", "throw", "new", "LogicException", "(", "'You must set a basket before calling getSubject'", ")", ";", "}", "return", "$", "this", "->", "app", "->", "tr...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php#L43-L50
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php
MailInfoPushReceived.getMessage
public function getMessage() { if (!$this->pusher) { throw new LogicException('You must set a basket before calling getMessage'); } if (!$this->basket) { throw new LogicException('You must set a basket before calling getMessage'); } return $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName()]) . "\n" . $this->message; }
php
public function getMessage() { if (!$this->pusher) { throw new LogicException('You must set a basket before calling getMessage'); } if (!$this->basket) { throw new LogicException('You must set a basket before calling getMessage'); } return $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName()]) . "\n" . $this->message; }
[ "public", "function", "getMessage", "(", ")", "{", "if", "(", "!", "$", "this", "->", "pusher", ")", "{", "throw", "new", "LogicException", "(", "'You must set a basket before calling getMessage'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "basket", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php#L55-L67
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php
Twitter.authenticate
public function authenticate(array $params = array()) { $params = array_merge(['providerId' => $this->getId()], $params); $code = $this->twitter->request( 'POST', $this->twitter->url('oauth/request_token', ''), ['oauth_callback' => $this->generator->generate( 'login_authentication_provider_callback', $params, UrlGenerator::ABSOLUTE_URL )] ); if ($code != 200) { throw new NotAuthenticatedException('Unable to request twitter token'); } $oauth = $this->twitter->extract_params($this->twitter->response['response']); $this->session->set('twitter.provider.oauth', $oauth); return new RedirectResponse(sprintf( '%s?%s', $this->twitter->url("oauth/authenticate", ''), http_build_query(['oauth_token' => $oauth['oauth_token']], '', '&') )); }
php
public function authenticate(array $params = array()) { $params = array_merge(['providerId' => $this->getId()], $params); $code = $this->twitter->request( 'POST', $this->twitter->url('oauth/request_token', ''), ['oauth_callback' => $this->generator->generate( 'login_authentication_provider_callback', $params, UrlGenerator::ABSOLUTE_URL )] ); if ($code != 200) { throw new NotAuthenticatedException('Unable to request twitter token'); } $oauth = $this->twitter->extract_params($this->twitter->response['response']); $this->session->set('twitter.provider.oauth', $oauth); return new RedirectResponse(sprintf( '%s?%s', $this->twitter->url("oauth/authenticate", ''), http_build_query(['oauth_token' => $oauth['oauth_token']], '', '&') )); }
[ "public", "function", "authenticate", "(", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "params", "=", "array_merge", "(", "[", "'providerId'", "=>", "$", "this", "->", "getId", "(", ")", "]", ",", "$", "params", ")", ";", "$", "c...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php#L72-L99
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php
Twitter.onCallback
public function onCallback(Request $request) { $oauth = $this->session->get('twitter.provider.oauth'); $this->twitter->config['user_token'] = $oauth['oauth_token']; $this->twitter->config['user_secret'] = $oauth['oauth_token_secret']; $code = $this->twitter->request( 'POST', $this->twitter->url('oauth/access_token', ''), ['oauth_verifier' => $request->query->get('oauth_verifier')] ); if ($code != 200) { throw new NotAuthenticatedException('Unable to get twitter access token'); } $access_token = $this->twitter->extract_params($this->twitter->response['response']); $this->session->set('twitter.provider.access_token', $access_token); $this->session->remove('twitter.provider.oauth'); $this->twitter->config['user_token'] = $access_token['oauth_token']; $this->twitter->config['user_secret'] = $access_token['oauth_token_secret']; $code = $this->twitter->request( 'GET', $this->twitter->url('1/account/verify_credentials') ); if ($code != 200) { throw new NotAuthenticatedException('Unable to get twitter credentials'); } $resp = @json_decode($this->twitter->response['response'], true); if (JSON_ERROR_NONE !== json_last_error()) { throw new NotAuthenticatedException('Unable to parse Twitter JSON response.'); } $this->session->set('twitter.provider.id', $resp['id']); }
php
public function onCallback(Request $request) { $oauth = $this->session->get('twitter.provider.oauth'); $this->twitter->config['user_token'] = $oauth['oauth_token']; $this->twitter->config['user_secret'] = $oauth['oauth_token_secret']; $code = $this->twitter->request( 'POST', $this->twitter->url('oauth/access_token', ''), ['oauth_verifier' => $request->query->get('oauth_verifier')] ); if ($code != 200) { throw new NotAuthenticatedException('Unable to get twitter access token'); } $access_token = $this->twitter->extract_params($this->twitter->response['response']); $this->session->set('twitter.provider.access_token', $access_token); $this->session->remove('twitter.provider.oauth'); $this->twitter->config['user_token'] = $access_token['oauth_token']; $this->twitter->config['user_secret'] = $access_token['oauth_token_secret']; $code = $this->twitter->request( 'GET', $this->twitter->url('1/account/verify_credentials') ); if ($code != 200) { throw new NotAuthenticatedException('Unable to get twitter credentials'); } $resp = @json_decode($this->twitter->response['response'], true); if (JSON_ERROR_NONE !== json_last_error()) { throw new NotAuthenticatedException('Unable to parse Twitter JSON response.'); } $this->session->set('twitter.provider.id', $resp['id']); }
[ "public", "function", "onCallback", "(", "Request", "$", "request", ")", "{", "$", "oauth", "=", "$", "this", "->", "session", "->", "get", "(", "'twitter.provider.oauth'", ")", ";", "$", "this", "->", "twitter", "->", "config", "[", "'user_token'", "]", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php#L112-L151
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php
Twitter.getToken
public function getToken() { if (0 >= $this->session->get('twitter.provider.id')) { throw new NotAuthenticatedException('Provider has not authenticated'); } return new Token($this, $this->session->get('twitter.provider.id')); }
php
public function getToken() { if (0 >= $this->session->get('twitter.provider.id')) { throw new NotAuthenticatedException('Provider has not authenticated'); } return new Token($this, $this->session->get('twitter.provider.id')); }
[ "public", "function", "getToken", "(", ")", "{", "if", "(", "0", ">=", "$", "this", "->", "session", "->", "get", "(", "'twitter.provider.id'", ")", ")", "{", "throw", "new", "NotAuthenticatedException", "(", "'Provider has not authenticated'", ")", ";", "}", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php#L156-L163
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php
Twitter.getIdentity
public function getIdentity() { $access_token = $this->session->get('twitter.provider.access_token'); $this->twitter->config['user_token'] = $access_token['oauth_token']; $this->twitter->config['user_secret'] = $access_token['oauth_token_secret']; $code = $this->twitter->request( 'GET', $this->twitter->url('1/account/verify_credentials') ); if ($code != 200) { throw new NotAuthenticatedException('Unable to retrieve twitter identity'); } $resp = @json_decode($this->twitter->response['response'], true); if (JSON_ERROR_NONE !== json_last_error()) { throw new NotAuthenticatedException('Unable to parse Twitter Identity JSON response.'); } $identity = new Identity(); $identity->set(Identity::PROPERTY_USERNAME, $resp['screen_name']); $identity->set(Identity::PROPERTY_IMAGEURL, $resp['profile_image_url_https']); $identity->set(Identity::PROPERTY_ID, $resp['id']); return $identity; }
php
public function getIdentity() { $access_token = $this->session->get('twitter.provider.access_token'); $this->twitter->config['user_token'] = $access_token['oauth_token']; $this->twitter->config['user_secret'] = $access_token['oauth_token_secret']; $code = $this->twitter->request( 'GET', $this->twitter->url('1/account/verify_credentials') ); if ($code != 200) { throw new NotAuthenticatedException('Unable to retrieve twitter identity'); } $resp = @json_decode($this->twitter->response['response'], true); if (JSON_ERROR_NONE !== json_last_error()) { throw new NotAuthenticatedException('Unable to parse Twitter Identity JSON response.'); } $identity = new Identity(); $identity->set(Identity::PROPERTY_USERNAME, $resp['screen_name']); $identity->set(Identity::PROPERTY_IMAGEURL, $resp['profile_image_url_https']); $identity->set(Identity::PROPERTY_ID, $resp['id']); return $identity; }
[ "public", "function", "getIdentity", "(", ")", "{", "$", "access_token", "=", "$", "this", "->", "session", "->", "get", "(", "'twitter.provider.access_token'", ")", ";", "$", "this", "->", "twitter", "->", "config", "[", "'user_token'", "]", "=", "$", "ac...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php#L168-L196
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php
Twitter.create
public static function create(UrlGenerator $generator, SessionInterface $session, array $options) { $twitter = new \tmhOAuth([ 'consumer_key' => $options['consumer-key'], 'consumer_secret' => $options['consumer-secret'], 'timezone' => date_default_timezone_get(), ]); return new Twitter($generator, $session, $twitter); }
php
public static function create(UrlGenerator $generator, SessionInterface $session, array $options) { $twitter = new \tmhOAuth([ 'consumer_key' => $options['consumer-key'], 'consumer_secret' => $options['consumer-secret'], 'timezone' => date_default_timezone_get(), ]); return new Twitter($generator, $session, $twitter); }
[ "public", "static", "function", "create", "(", "UrlGenerator", "$", "generator", ",", "SessionInterface", "$", "session", ",", "array", "$", "options", ")", "{", "$", "twitter", "=", "new", "\\", "tmhOAuth", "(", "[", "'consumer_key'", "=>", "$", "options", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php#L251-L260
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Dailymotion.php
Bridge_Api_Dailymotion.list_elements
public function list_elements($object, $offset_start = 0, $quantity = 10) { switch ($object) { case self::ELEMENT_TYPE_VIDEO: $result = $this->_api->call('/me/videos', ['fields' => [ 'created_time' , 'description' , 'duration' , 'modified_time' , 'private' , 'rating' , 'ratings_total' , 'thumbnail_small_url' , 'thumbnail_medium_url' , 'title' , 'url' , 'views_total' , 'id' , 'channel' ], 'page' => ! $offset_start ? 1 : $offset_start, 'limit' => $quantity], $this->oauth_token); $element_collection = new Bridge_Api_ElementCollection(); $element_collection->set_items_per_page($result["limit"]); $total = sizeof($result["list"]); $current_page = $result["page"]; $total_page = null; $element_collection->set_total_items($total); $element_collection->set_current_page($current_page); $element_collection->set_total_page($total_page); foreach ($result["list"] as $entry) { $element_collection->add_element(new Bridge_Api_Dailymotion_Element($entry, $object)); } return $element_collection; break; default: throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } }
php
public function list_elements($object, $offset_start = 0, $quantity = 10) { switch ($object) { case self::ELEMENT_TYPE_VIDEO: $result = $this->_api->call('/me/videos', ['fields' => [ 'created_time' , 'description' , 'duration' , 'modified_time' , 'private' , 'rating' , 'ratings_total' , 'thumbnail_small_url' , 'thumbnail_medium_url' , 'title' , 'url' , 'views_total' , 'id' , 'channel' ], 'page' => ! $offset_start ? 1 : $offset_start, 'limit' => $quantity], $this->oauth_token); $element_collection = new Bridge_Api_ElementCollection(); $element_collection->set_items_per_page($result["limit"]); $total = sizeof($result["list"]); $current_page = $result["page"]; $total_page = null; $element_collection->set_total_items($total); $element_collection->set_current_page($current_page); $element_collection->set_total_page($total_page); foreach ($result["list"] as $entry) { $element_collection->add_element(new Bridge_Api_Dailymotion_Element($entry, $object)); } return $element_collection; break; default: throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } }
[ "public", "function", "list_elements", "(", "$", "object", ",", "$", "offset_start", "=", "0", ",", "$", "quantity", "=", "10", ")", "{", "switch", "(", "$", "object", ")", "{", "case", "self", "::", "ELEMENT_TYPE_VIDEO", ":", "$", "result", "=", "$", ...
@todo Pagination system @see http://www.dailymotion.com/doc/api/advanced-api.html @param string $object @param int $offset_start @param int $quantity @return Bridge_Api_ElementCollection
[ "@todo", "Pagination", "system" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Dailymotion.php#L227-L272
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Dailymotion.php
Bridge_Api_Dailymotion.list_containers
public function list_containers($object, $offset_start = 0, $quantity = 10) { switch ($object) { case self::CONTAINER_TYPE_PLAYLIST: $username = $this->get_user_name(); $params = ['fields' => [ 'description' , 'id' , 'name' ], 'page' => ! $offset_start ? 1 : $offset_start]; //add quantity if (! ! $quantity) { $params["limit"] = $quantity; } $url = sprintf('/me/%ss', $object); $result = $this->_api->call($url, $params, $this->oauth_token); $container_collection = new Bridge_Api_ContainerCollection(); $container_collection->set_items_per_page($result["limit"]); $total = sizeof($result["list"]); $current_page = $result["limit"]; $total_page = null; $container_collection->set_total_items($total); $container_collection->set_current_page($current_page); $container_collection->set_total_page($total_page); foreach ($result['list'] as $entry) { //get 1st image $list_element = $this->list_containers_content($object, $entry['id'], ['thumbnail_medium_url'], 1); $elements = $list_element->get_elements(); $first_element = array_shift($elements); $thumbnail = $first_element instanceof Bridge_Api_Dailymotion_Element ? $first_element->get_thumbnail() : ''; $url = $this->get_url_playlist($entry['id'], $entry['name'], $username); $container_collection->add_element(new Bridge_Api_Dailymotion_Container($entry, $object, $thumbnail, $url)); } return $container_collection; break; default: throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } }
php
public function list_containers($object, $offset_start = 0, $quantity = 10) { switch ($object) { case self::CONTAINER_TYPE_PLAYLIST: $username = $this->get_user_name(); $params = ['fields' => [ 'description' , 'id' , 'name' ], 'page' => ! $offset_start ? 1 : $offset_start]; //add quantity if (! ! $quantity) { $params["limit"] = $quantity; } $url = sprintf('/me/%ss', $object); $result = $this->_api->call($url, $params, $this->oauth_token); $container_collection = new Bridge_Api_ContainerCollection(); $container_collection->set_items_per_page($result["limit"]); $total = sizeof($result["list"]); $current_page = $result["limit"]; $total_page = null; $container_collection->set_total_items($total); $container_collection->set_current_page($current_page); $container_collection->set_total_page($total_page); foreach ($result['list'] as $entry) { //get 1st image $list_element = $this->list_containers_content($object, $entry['id'], ['thumbnail_medium_url'], 1); $elements = $list_element->get_elements(); $first_element = array_shift($elements); $thumbnail = $first_element instanceof Bridge_Api_Dailymotion_Element ? $first_element->get_thumbnail() : ''; $url = $this->get_url_playlist($entry['id'], $entry['name'], $username); $container_collection->add_element(new Bridge_Api_Dailymotion_Container($entry, $object, $thumbnail, $url)); } return $container_collection; break; default: throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } }
[ "public", "function", "list_containers", "(", "$", "object", ",", "$", "offset_start", "=", "0", ",", "$", "quantity", "=", "10", ")", "{", "switch", "(", "$", "object", ")", "{", "case", "self", "::", "CONTAINER_TYPE_PLAYLIST", ":", "$", "username", "="...
@Todo recupérer la thumbnail d'une playlist @param string $object @param int $offset_start @param int $quantity @return Bridge_Api_ContainerCollection
[ "@Todo", "recupérer", "la", "thumbnail", "d", "une", "playlist" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Dailymotion.php#L282-L333
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Dailymotion.php
Bridge_Api_Dailymotion.handle_exception
public function handle_exception(Exception $e) { if ($e instanceof DailymotionAuthException) { $e = new Bridge_Exception_ActionAuthNeedReconnect($e->getMessage()); } elseif ($e instanceof DailymotionApiException || $e instanceof DailymotionAuthRequiredException) { $e = new Exception($e->getMessage(), $e->getCode()); } return; }
php
public function handle_exception(Exception $e) { if ($e instanceof DailymotionAuthException) { $e = new Bridge_Exception_ActionAuthNeedReconnect($e->getMessage()); } elseif ($e instanceof DailymotionApiException || $e instanceof DailymotionAuthRequiredException) { $e = new Exception($e->getMessage(), $e->getCode()); } return; }
[ "public", "function", "handle_exception", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "DailymotionAuthException", ")", "{", "$", "e", "=", "new", "Bridge_Exception_ActionAuthNeedReconnect", "(", "$", "e", "->", "getMessage", "(", "...
Set The exception to Bridge_Exception_ActionAuthNeedReconnect if exception is instance of Zend_Gdata_App_HttpException and Http code 401 @param Exception $e @return Void
[ "Set", "The", "exception", "to", "Bridge_Exception_ActionAuthNeedReconnect", "if", "exception", "is", "instance", "of", "Zend_Gdata_App_HttpException", "and", "Http", "code", "401" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Dailymotion.php#L546-L555
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Dailymotion.php
Bridge_Api_Dailymotion.check_upload_constraints
public function check_upload_constraints(Array $datas, record_adapter $record) { $errors = $this->check_record_constraints($record); $check = function ($field) use (&$errors, $datas, $record) { $key = $record->getId(); $required = ! ! $field["required"]; $name = $field["name"]; $length = (int) $field["length"]; $length_min = (int) $field["length_min"]; if ( ! isset($datas[$name]) || trim($datas[$name]) === '') { if ($required) $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est obligatoire"); } else { if ($length != 0 && mb_strlen($datas[$name]) > $length) $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est trop long %length% caracteres max", ['%length%' => $length]); if ($length_min != 0 && mb_strlen($datas[$name]) < $length_min) $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est trop court %length% caracteres min", ['%length%' => $length_min]); } }; array_map($check, $this->get_fields()); return $errors; }
php
public function check_upload_constraints(Array $datas, record_adapter $record) { $errors = $this->check_record_constraints($record); $check = function ($field) use (&$errors, $datas, $record) { $key = $record->getId(); $required = ! ! $field["required"]; $name = $field["name"]; $length = (int) $field["length"]; $length_min = (int) $field["length_min"]; if ( ! isset($datas[$name]) || trim($datas[$name]) === '') { if ($required) $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est obligatoire"); } else { if ($length != 0 && mb_strlen($datas[$name]) > $length) $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est trop long %length% caracteres max", ['%length%' => $length]); if ($length_min != 0 && mb_strlen($datas[$name]) < $length_min) $errors[$name . '_' . $key] = $this->translator->trans("Ce champ est trop court %length% caracteres min", ['%length%' => $length_min]); } }; array_map($check, $this->get_fields()); return $errors; }
[ "public", "function", "check_upload_constraints", "(", "Array", "$", "datas", ",", "record_adapter", "$", "record", ")", "{", "$", "errors", "=", "$", "this", "->", "check_record_constraints", "(", "$", "record", ")", ";", "$", "check", "=", "function", "(",...
@todo implement in bridge_api°interface Check if data uploaded via the current connector is conform @param array $datas @param record_adapter $record @return array
[ "@todo", "implement", "in", "bridge_api°interface" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Dailymotion.php#L786-L810
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Dailymotion.php
Bridge_Api_Dailymotion.get_update_datas
public function get_update_datas(Request $request) { $datas = [ 'title' => $request->get('modif_title'), 'description' => $request->get('modif_description'), 'tags' => $request->get('modif_tags'), 'private' => $request->get('modif_privacy') === 'private' ? true : false, ]; return $datas; }
php
public function get_update_datas(Request $request) { $datas = [ 'title' => $request->get('modif_title'), 'description' => $request->get('modif_description'), 'tags' => $request->get('modif_tags'), 'private' => $request->get('modif_privacy') === 'private' ? true : false, ]; return $datas; }
[ "public", "function", "get_update_datas", "(", "Request", "$", "request", ")", "{", "$", "datas", "=", "[", "'title'", "=>", "$", "request", "->", "get", "(", "'modif_title'", ")", ",", "'description'", "=>", "$", "request", "->", "get", "(", "'modif_descr...
Returns datas needed for an uploaded record @param Request $request @return array
[ "Returns", "datas", "needed", "for", "an", "uploaded", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Dailymotion.php#L863-L873
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Order/Controller/ProdOrderController.php
ProdOrderController.createOrder
public function createOrder(Request $request) { $records = RecordsRequest::fromRequest($this->app, $request, true, [\ACL::CANCMD]); try { if ($records->isEmpty()) { throw new OrderControllerException($this->app->trans('There is no record eligible for an order')); } if (null !== $deadLine = $request->request->get('deadline')) { $deadLine = new \DateTime($deadLine); } $orderUsage = $request->request->get('use', ''); $order = new Order(); $order->setUser($this->getAuthenticatedUser()); $order->setDeadline($deadLine); $order->setOrderUsage($orderUsage); $filler = new OrderFiller($this->app['repo.collection-references'], $this->getEntityManager()); try { $filler->assertAllRecordsHaveOrderMaster($records); } catch (\RuntimeException $exception) { throw new OrderControllerException($this->app->trans('There is no one to validate orders, please contact an administrator')); } $filler->fillOrder($order, $records); $this->dispatch(PhraseaEvents::ORDER_CREATE, new OrderEvent($order)); $success = true; $msg = $this->app->trans('The records have been properly ordered'); } catch (OrderControllerException $exception) { $success = false; $msg = $exception->getMessage(); } catch (\Exception $exception) { $success = false; $msg = $this->app->trans('An error occurred'); } if ('json' === $request->getRequestFormat()) { return $this->app->json([ 'success' => $success, 'msg' => $msg, ]); } return $this->app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send', ]); }
php
public function createOrder(Request $request) { $records = RecordsRequest::fromRequest($this->app, $request, true, [\ACL::CANCMD]); try { if ($records->isEmpty()) { throw new OrderControllerException($this->app->trans('There is no record eligible for an order')); } if (null !== $deadLine = $request->request->get('deadline')) { $deadLine = new \DateTime($deadLine); } $orderUsage = $request->request->get('use', ''); $order = new Order(); $order->setUser($this->getAuthenticatedUser()); $order->setDeadline($deadLine); $order->setOrderUsage($orderUsage); $filler = new OrderFiller($this->app['repo.collection-references'], $this->getEntityManager()); try { $filler->assertAllRecordsHaveOrderMaster($records); } catch (\RuntimeException $exception) { throw new OrderControllerException($this->app->trans('There is no one to validate orders, please contact an administrator')); } $filler->fillOrder($order, $records); $this->dispatch(PhraseaEvents::ORDER_CREATE, new OrderEvent($order)); $success = true; $msg = $this->app->trans('The records have been properly ordered'); } catch (OrderControllerException $exception) { $success = false; $msg = $exception->getMessage(); } catch (\Exception $exception) { $success = false; $msg = $this->app->trans('An error occurred'); } if ('json' === $request->getRequestFormat()) { return $this->app->json([ 'success' => $success, 'msg' => $msg, ]); } return $this->app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send', ]); }
[ "public", "function", "createOrder", "(", "Request", "$", "request", ")", "{", "$", "records", "=", "RecordsRequest", "::", "fromRequest", "(", "$", "this", "->", "app", ",", "$", "request", ",", "true", ",", "[", "\\", "ACL", "::", "CANCMD", "]", ")",...
Create a new order @param Request $request @return RedirectResponse|JsonResponse
[ "Create", "a", "new", "order" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Order/Controller/ProdOrderController.php#L38-L91
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Order/Controller/ProdOrderController.php
ProdOrderController.displayOrders
public function displayOrders(Request $request) { $page = (int) $request->query->get('page', 1); $perPage = (int) $request->query->get('per-page', 10); $offsetStart = 0; $todo = $request->query->get('todo', Order::STATUS_TODO); $start = $request->query->get('start', Order::STATUS_NO_FILTER); $limit = $request->query->get('limit', []); if ($page > 0) { $offsetStart = ($page - 1) * $perPage; } $sort = $request->query->get('sort'); $baseIds = array_keys($this->getAclForUser()->get_granted_base([\ACL::ORDER_MASTER])); $ordersListTodo = $this->getOrderRepository()->listOrders($baseIds, $offsetStart, $perPage, $sort, ['todo' => Order::STATUS_TODO, 'created_on' => $start, 'limit' => $limit]); $ordersListProcessed = $this->getOrderRepository()->listOrders($baseIds, $offsetStart, $perPage, $sort, ['todo' => Order::STATUS_PROCESSED, 'created_on' => $start, 'limit' => $limit]); $totalTodo = $this->getOrderRepository()->countTotalOrders($baseIds, ['todo' => Order::STATUS_TODO, 'created_on' => $start, 'limit' => $limit]); $totalProcessed = $this->getOrderRepository()->countTotalOrders($baseIds, ['todo' => Order::STATUS_PROCESSED, 'created_on' => $start, 'limit' => $limit]); return $this->render('prod/orders/order_box.html.twig', [ 'page' => $page, 'perPage' => $perPage, 'totalTodo' => $totalTodo, 'totalProcessed' => $totalProcessed, 'orders_todo' => new ArrayCollection($ordersListTodo), 'orders_processed' => new ArrayCollection($ordersListProcessed), 'todo' => $todo, 'start' => $start, 'date' => $limit ? $limit['date']: null ]); }
php
public function displayOrders(Request $request) { $page = (int) $request->query->get('page', 1); $perPage = (int) $request->query->get('per-page', 10); $offsetStart = 0; $todo = $request->query->get('todo', Order::STATUS_TODO); $start = $request->query->get('start', Order::STATUS_NO_FILTER); $limit = $request->query->get('limit', []); if ($page > 0) { $offsetStart = ($page - 1) * $perPage; } $sort = $request->query->get('sort'); $baseIds = array_keys($this->getAclForUser()->get_granted_base([\ACL::ORDER_MASTER])); $ordersListTodo = $this->getOrderRepository()->listOrders($baseIds, $offsetStart, $perPage, $sort, ['todo' => Order::STATUS_TODO, 'created_on' => $start, 'limit' => $limit]); $ordersListProcessed = $this->getOrderRepository()->listOrders($baseIds, $offsetStart, $perPage, $sort, ['todo' => Order::STATUS_PROCESSED, 'created_on' => $start, 'limit' => $limit]); $totalTodo = $this->getOrderRepository()->countTotalOrders($baseIds, ['todo' => Order::STATUS_TODO, 'created_on' => $start, 'limit' => $limit]); $totalProcessed = $this->getOrderRepository()->countTotalOrders($baseIds, ['todo' => Order::STATUS_PROCESSED, 'created_on' => $start, 'limit' => $limit]); return $this->render('prod/orders/order_box.html.twig', [ 'page' => $page, 'perPage' => $perPage, 'totalTodo' => $totalTodo, 'totalProcessed' => $totalProcessed, 'orders_todo' => new ArrayCollection($ordersListTodo), 'orders_processed' => new ArrayCollection($ordersListProcessed), 'todo' => $todo, 'start' => $start, 'date' => $limit ? $limit['date']: null ]); }
[ "public", "function", "displayOrders", "(", "Request", "$", "request", ")", "{", "$", "page", "=", "(", "int", ")", "$", "request", "->", "query", "->", "get", "(", "'page'", ",", "1", ")", ";", "$", "perPage", "=", "(", "int", ")", "$", "request",...
Display list of orders @param Request $request @return Response
[ "Display", "list", "of", "orders" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Order/Controller/ProdOrderController.php#L100-L136
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Order/Controller/ProdOrderController.php
ProdOrderController.sendOrder
public function sendOrder(Request $request, $order_id) { $elementIds = $request->request->get('elements', []); $acceptor = $this->getAuthenticatedUser(); $basketElements = $this->doAcceptElements($order_id, $elementIds, $acceptor); $success = !empty($basketElements); if ('json' === $request->getRequestFormat()) { return $this->app->json([ 'success' => $success, 'msg' => $success ? $this->app->trans('Order has been sent') : $this->app->trans('An error occured while sending, please retry or contact an admin if problem persists'), 'order_id' => $order_id, ]); } return $this->app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send', ]); }
php
public function sendOrder(Request $request, $order_id) { $elementIds = $request->request->get('elements', []); $acceptor = $this->getAuthenticatedUser(); $basketElements = $this->doAcceptElements($order_id, $elementIds, $acceptor); $success = !empty($basketElements); if ('json' === $request->getRequestFormat()) { return $this->app->json([ 'success' => $success, 'msg' => $success ? $this->app->trans('Order has been sent') : $this->app->trans('An error occured while sending, please retry or contact an admin if problem persists'), 'order_id' => $order_id, ]); } return $this->app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send', ]); }
[ "public", "function", "sendOrder", "(", "Request", "$", "request", ",", "$", "order_id", ")", "{", "$", "elementIds", "=", "$", "request", "->", "request", "->", "get", "(", "'elements'", ",", "[", "]", ")", ";", "$", "acceptor", "=", "$", "this", "-...
Send an order @param Request $request @param integer $order_id @return RedirectResponse|JsonResponse
[ "Send", "an", "order" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Order/Controller/ProdOrderController.php#L160-L183
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Order/Controller/ProdOrderController.php
ProdOrderController.denyOrder
public function denyOrder(Request $request, $order_id) { $elementIds = $request->request->get('elements', []); $acceptor = $this->getAuthenticatedUser(); $elements = $this->doDenyElements($order_id, $elementIds, $acceptor); $success = !empty($elements); if ('json' === $request->getRequestFormat()) { return $this->app->json([ 'success' => $success, 'msg' => $success ? $this->app->trans('Order has been denied') : $this->app->trans('An error occured while denying, please retry or contact an admin if problem persists'), 'order_id' => $order_id, ]); } return $this->app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send', ]); }
php
public function denyOrder(Request $request, $order_id) { $elementIds = $request->request->get('elements', []); $acceptor = $this->getAuthenticatedUser(); $elements = $this->doDenyElements($order_id, $elementIds, $acceptor); $success = !empty($elements); if ('json' === $request->getRequestFormat()) { return $this->app->json([ 'success' => $success, 'msg' => $success ? $this->app->trans('Order has been denied') : $this->app->trans('An error occured while denying, please retry or contact an admin if problem persists'), 'order_id' => $order_id, ]); } return $this->app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send', ]); }
[ "public", "function", "denyOrder", "(", "Request", "$", "request", ",", "$", "order_id", ")", "{", "$", "elementIds", "=", "$", "request", "->", "request", "->", "get", "(", "'elements'", ",", "[", "]", ")", ";", "$", "acceptor", "=", "$", "this", "-...
Deny an order @param Request $request @param integer $order_id @return RedirectResponse|JsonResponse
[ "Deny", "an", "order" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Order/Controller/ProdOrderController.php#L192-L215
alchemy-fr/Phraseanet
lib/classes/Bridge/Element.php
Bridge_Element.set_uploaded_on
public function set_uploaded_on(DateTime $date = null) { $this->uploaded_on = $date; $this->updated_on = new DateTime(); $sql = 'UPDATE bridge_elements SET uploaded_on = :uploaded_on, updated_on = :update WHERE id = :id'; $params = [ ':uploaded_on' => NullableDateTime::format($this->uploaded_on, DATE_ISO8601), ':id' => $this->id, ':update' => $this->updated_on->format(DATE_ISO8601), ]; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); return $this; }
php
public function set_uploaded_on(DateTime $date = null) { $this->uploaded_on = $date; $this->updated_on = new DateTime(); $sql = 'UPDATE bridge_elements SET uploaded_on = :uploaded_on, updated_on = :update WHERE id = :id'; $params = [ ':uploaded_on' => NullableDateTime::format($this->uploaded_on, DATE_ISO8601), ':id' => $this->id, ':update' => $this->updated_on->format(DATE_ISO8601), ]; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); return $this; }
[ "public", "function", "set_uploaded_on", "(", "DateTime", "$", "date", "=", "null", ")", "{", "$", "this", "->", "uploaded_on", "=", "$", "date", ";", "$", "this", "->", "updated_on", "=", "new", "DateTime", "(", ")", ";", "$", "sql", "=", "'UPDATE bri...
@todo write tests @return DateTime
[ "@todo", "write", "tests" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Element.php#L378-L397
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/SearchEngine/Elastic/FieldMapping.php
FieldMapping.buildArray
private function buildArray(array $fieldProperties = []) { $baseProperties = [ ]; if ($this->type !== self::TYPE_OBJECT) { $baseProperties['type'] = $this->type; } else { $baseProperties['properties'] = []; } if (! $this->indexed) { $baseProperties['index'] = 'no'; } elseif ($this->raw) { $baseProperties['index'] = 'not_analyzed'; } if (! $this->enabled) { $baseProperties['enabled'] = false; } return array_replace($baseProperties, $fieldProperties); }
php
private function buildArray(array $fieldProperties = []) { $baseProperties = [ ]; if ($this->type !== self::TYPE_OBJECT) { $baseProperties['type'] = $this->type; } else { $baseProperties['properties'] = []; } if (! $this->indexed) { $baseProperties['index'] = 'no'; } elseif ($this->raw) { $baseProperties['index'] = 'not_analyzed'; } if (! $this->enabled) { $baseProperties['enabled'] = false; } return array_replace($baseProperties, $fieldProperties); }
[ "private", "function", "buildArray", "(", "array", "$", "fieldProperties", "=", "[", "]", ")", "{", "$", "baseProperties", "=", "[", "]", ";", "if", "(", "$", "this", "->", "type", "!==", "self", "::", "TYPE_OBJECT", ")", "{", "$", "baseProperties", "[...
Helper function to append custom field properties to generic properties array @param array $fieldProperties @return array
[ "Helper", "function", "to", "append", "custom", "field", "properties", "to", "generic", "properties", "array" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/SearchEngine/Elastic/FieldMapping.php#L189-L210
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php
ACLManipulator.resetAdminRights
public function resetAdminRights($users) { foreach ($this->makeTraversable($users) as $user) { $this->doResetAdminRights($user); } }
php
public function resetAdminRights($users) { foreach ($this->makeTraversable($users) as $user) { $this->doResetAdminRights($user); } }
[ "public", "function", "resetAdminRights", "(", "$", "users", ")", "{", "foreach", "(", "$", "this", "->", "makeTraversable", "(", "$", "users", ")", "as", "$", "user", ")", "{", "$", "this", "->", "doResetAdminRights", "(", "$", "user", ")", ";", "}", ...
Resets rights for users. @param User[] $users @throws InvalidArgumentException
[ "Resets", "rights", "for", "users", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php#L38-L43
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php
ACLManipulator.doResetAdminRights
private function doResetAdminRights(User $user) { $acl = $this->ACLProvider->get($user); $databoxes = $this->appbox->get_databoxes(); $acl->give_access_to_sbas(array_map(function (\databox $databox) { return $databox->get_sbas_id(); }, $databoxes)); foreach ($databoxes as $databox) { $this->doResetAdminRightsOnDatabox($acl, $databox); } }
php
private function doResetAdminRights(User $user) { $acl = $this->ACLProvider->get($user); $databoxes = $this->appbox->get_databoxes(); $acl->give_access_to_sbas(array_map(function (\databox $databox) { return $databox->get_sbas_id(); }, $databoxes)); foreach ($databoxes as $databox) { $this->doResetAdminRightsOnDatabox($acl, $databox); } }
[ "private", "function", "doResetAdminRights", "(", "User", "$", "user", ")", "{", "$", "acl", "=", "$", "this", "->", "ACLProvider", "->", "get", "(", "$", "user", ")", ";", "$", "databoxes", "=", "$", "this", "->", "appbox", "->", "get_databoxes", "(",...
Resets rights for a user. @param User $user
[ "Resets", "rights", "for", "a", "user", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php#L50-L62
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php
ACLManipulator.doResetAdminRightsOnDatabox
private function doResetAdminRightsOnDatabox(\ACL $acl, \databox $databox) { $collections = $databox->get_collections(); $acl->update_rights_to_sbas( $databox->get_sbas_id(), [ \ACL::BAS_MANAGE => true, \ACL::BAS_MODIFY_STRUCT => true, \ACL::BAS_MODIF_TH => true, \ACL::BAS_CHUPUB => true ] ); $acl->give_access_to_base(array_map(function (\collection $collection) { return $collection->get_base_id(); }, $collections)); foreach ($collections as $collection) { $this->doResetRightsOnCollection($acl, $collection); } }
php
private function doResetAdminRightsOnDatabox(\ACL $acl, \databox $databox) { $collections = $databox->get_collections(); $acl->update_rights_to_sbas( $databox->get_sbas_id(), [ \ACL::BAS_MANAGE => true, \ACL::BAS_MODIFY_STRUCT => true, \ACL::BAS_MODIF_TH => true, \ACL::BAS_CHUPUB => true ] ); $acl->give_access_to_base(array_map(function (\collection $collection) { return $collection->get_base_id(); }, $collections)); foreach ($collections as $collection) { $this->doResetRightsOnCollection($acl, $collection); } }
[ "private", "function", "doResetAdminRightsOnDatabox", "(", "\\", "ACL", "$", "acl", ",", "\\", "databox", "$", "databox", ")", "{", "$", "collections", "=", "$", "databox", "->", "get_collections", "(", ")", ";", "$", "acl", "->", "update_rights_to_sbas", "(...
Resets admin rights on a databox. @param \ACL $acl @param \databox $databox
[ "Resets", "admin", "rights", "on", "a", "databox", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php#L70-L91
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php
ACLManipulator.doResetRightsOnCollection
private function doResetRightsOnCollection(\ACL $acl, \collection $collection) { $baseId = $collection->get_base_id(); $acl->set_limits($baseId, false); $acl->remove_quotas_on_base($baseId); $acl->set_masks_on_base($baseId, '0', '0', '0', '0'); $acl->update_rights_to_base( $baseId, [ 'creationdate' => '1', // todo : wtf \ACL::CANPUTINALBUM => true, \ACL::CANDWNLDHD => true, \ACL::NOWATERMARK => true, \ACL::CANDWNLDPREVIEW => true, \ACL::CANCMD => true, \ACL::CANADMIN => true, \ACL::CANREPORT => true, \ACL::CANPUSH => true, \ACL::CANADDRECORD => true, \ACL::CANMODIFRECORD => true, \ACL::CANDELETERECORD => true, \ACL::CHGSTATUS => true, \ACL::IMGTOOLS => true, \ACL::COLL_MANAGE => true, \ACL::COLL_MODIFY_STRUCT => true, \ACL::BAS_MODIFY_STRUCT => true ] ); }
php
private function doResetRightsOnCollection(\ACL $acl, \collection $collection) { $baseId = $collection->get_base_id(); $acl->set_limits($baseId, false); $acl->remove_quotas_on_base($baseId); $acl->set_masks_on_base($baseId, '0', '0', '0', '0'); $acl->update_rights_to_base( $baseId, [ 'creationdate' => '1', // todo : wtf \ACL::CANPUTINALBUM => true, \ACL::CANDWNLDHD => true, \ACL::NOWATERMARK => true, \ACL::CANDWNLDPREVIEW => true, \ACL::CANCMD => true, \ACL::CANADMIN => true, \ACL::CANREPORT => true, \ACL::CANPUSH => true, \ACL::CANADDRECORD => true, \ACL::CANMODIFRECORD => true, \ACL::CANDELETERECORD => true, \ACL::CHGSTATUS => true, \ACL::IMGTOOLS => true, \ACL::COLL_MANAGE => true, \ACL::COLL_MODIFY_STRUCT => true, \ACL::BAS_MODIFY_STRUCT => true ] ); }
[ "private", "function", "doResetRightsOnCollection", "(", "\\", "ACL", "$", "acl", ",", "\\", "collection", "$", "collection", ")", "{", "$", "baseId", "=", "$", "collection", "->", "get_base_id", "(", ")", ";", "$", "acl", "->", "set_limits", "(", "$", "...
Resets admin rights on a collection. @param \ACL $acl @param \collection $collection
[ "Resets", "admin", "rights", "on", "a", "collection", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php#L99-L128
alchemy-fr/Phraseanet
lib/classes/eventsmanager/notify/autoregister.php
eventsmanager_notify_autoregister.is_available
public function is_available(User $user) { if (! $this->app['registration.manager']->isRegistrationEnabled()) { return false; } return $this->app->getAclForUser($user)->has_right(\ACL::CANADMIN); }
php
public function is_available(User $user) { if (! $this->app['registration.manager']->isRegistrationEnabled()) { return false; } return $this->app->getAclForUser($user)->has_right(\ACL::CANADMIN); }
[ "public", "function", "is_available", "(", "User", "$", "user", ")", "{", "if", "(", "!", "$", "this", "->", "app", "[", "'registration.manager'", "]", "->", "isRegistrationEnabled", "(", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this",...
@param integer $usr_id The id of the user to check @return boolean
[ "@param", "integer", "$usr_id", "The", "id", "of", "the", "user", "to", "check" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/eventsmanager/notify/autoregister.php#L70-L77
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/ControllerProvider/Prod/Order.php
Order.connect
public function connect(Application $app) { $controllers = $this->createAuthenticatedCollection($app); $firewall = $this->getFirewall($app); $ensureOrdersAdmin = function () use ($firewall) { $firewall->requireOrdersAdmin(); }; $controllers->before(function () use ($firewall) { $firewall->requireRight(\ACL::CANCMD); }); $controllers->get('/', 'controller.prod.order:displayOrders') ->before($ensureOrdersAdmin) ->bind('prod_orders'); $controllers->post('/', 'controller.prod.order:createOrder') ->bind('prod_order_new'); $controllers->get('/{order_id}/', 'controller.prod.order:displayOneOrder') ->before($ensureOrdersAdmin) ->bind('prod_order') ->assert('order_id', '\d+'); $controllers->post('/{order_id}/send/', 'controller.prod.order:sendOrder') ->before($ensureOrdersAdmin) ->bind('prod_order_send') ->assert('order_id', '\d+'); $controllers->post('/{order_id}/deny/', 'controller.prod.order:denyOrder') ->before($ensureOrdersAdmin) ->bind('prod_order_deny') ->assert('order_id', '\d+'); return $controllers; }
php
public function connect(Application $app) { $controllers = $this->createAuthenticatedCollection($app); $firewall = $this->getFirewall($app); $ensureOrdersAdmin = function () use ($firewall) { $firewall->requireOrdersAdmin(); }; $controllers->before(function () use ($firewall) { $firewall->requireRight(\ACL::CANCMD); }); $controllers->get('/', 'controller.prod.order:displayOrders') ->before($ensureOrdersAdmin) ->bind('prod_orders'); $controllers->post('/', 'controller.prod.order:createOrder') ->bind('prod_order_new'); $controllers->get('/{order_id}/', 'controller.prod.order:displayOneOrder') ->before($ensureOrdersAdmin) ->bind('prod_order') ->assert('order_id', '\d+'); $controllers->post('/{order_id}/send/', 'controller.prod.order:sendOrder') ->before($ensureOrdersAdmin) ->bind('prod_order_send') ->assert('order_id', '\d+'); $controllers->post('/{order_id}/deny/', 'controller.prod.order:denyOrder') ->before($ensureOrdersAdmin) ->bind('prod_order_deny') ->assert('order_id', '\d+'); return $controllers; }
[ "public", "function", "connect", "(", "Application", "$", "app", ")", "{", "$", "controllers", "=", "$", "this", "->", "createAuthenticatedCollection", "(", "$", "app", ")", ";", "$", "firewall", "=", "$", "this", "->", "getFirewall", "(", "$", "app", ")...
{@inheritDoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/ControllerProvider/Prod/Order.php#L66-L101
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php
DisplaySettingService.getUserSetting
public function getUserSetting(User $user, $name, $default = null) { if (false === $user->getSettings()->containsKey($name)) { $this->loadusersSettings(); return array_key_exists($name, $this->usersSettings) ? $this->usersSettings[$name] : $default; } return $user->getSettings()->get($name)->getValue(); }
php
public function getUserSetting(User $user, $name, $default = null) { if (false === $user->getSettings()->containsKey($name)) { $this->loadusersSettings(); return array_key_exists($name, $this->usersSettings) ? $this->usersSettings[$name] : $default; } return $user->getSettings()->get($name)->getValue(); }
[ "public", "function", "getUserSetting", "(", "User", "$", "user", ",", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "false", "===", "$", "user", "->", "getSettings", "(", ")", "->", "containsKey", "(", "$", "name", ")", ")", ...
Return a user setting given a user. @param User $user @param string $name @param mixed $default @return mixed
[ "Return", "a", "user", "setting", "given", "a", "user", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php#L90-L99
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php
DisplaySettingService.getUserNotificationSetting
public function getUserNotificationSetting(User $user, $name, $default = true) { if (false === $user->getNotificationSettings()->containsKey($name)) { return $default; } return $user->getNotificationSettings()->get($name)->getValue(); }
php
public function getUserNotificationSetting(User $user, $name, $default = true) { if (false === $user->getNotificationSettings()->containsKey($name)) { return $default; } return $user->getNotificationSettings()->get($name)->getValue(); }
[ "public", "function", "getUserNotificationSetting", "(", "User", "$", "user", ",", "$", "name", ",", "$", "default", "=", "true", ")", "{", "if", "(", "false", "===", "$", "user", "->", "getNotificationSettings", "(", ")", "->", "containsKey", "(", "$", ...
Return a user notification setting given a user. @param User $user @param string $name @param mixed $default @return mixed
[ "Return", "a", "user", "notification", "setting", "given", "a", "user", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php#L110-L117
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php
DisplaySettingService.getApplicationSetting
public function getApplicationSetting($props, $default = null) { return $this->conf->get(array_merge(['registry'], is_array($props) ? $props : [$props]), $default); }
php
public function getApplicationSetting($props, $default = null) { return $this->conf->get(array_merge(['registry'], is_array($props) ? $props : [$props]), $default); }
[ "public", "function", "getApplicationSetting", "(", "$", "props", ",", "$", "default", "=", "null", ")", "{", "return", "$", "this", "->", "conf", "->", "get", "(", "array_merge", "(", "[", "'registry'", "]", ",", "is_array", "(", "$", "props", ")", "?...
Returns application setting value. @param string|array $props @param mixed $default @return mixed
[ "Returns", "application", "setting", "value", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php#L127-L130
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php
DisplaySettingService.loadUsersSettings
private function loadUsersSettings() { if (null !== $this->usersSettings) { return; } $this->usersSettings = array_replace( self::$defaultUserSettings, // removes undefined keys in default settings array_intersect_key( $this->conf->get(['user-settings'], []), self::$defaultUserSettings ) ); }
php
private function loadUsersSettings() { if (null !== $this->usersSettings) { return; } $this->usersSettings = array_replace( self::$defaultUserSettings, // removes undefined keys in default settings array_intersect_key( $this->conf->get(['user-settings'], []), self::$defaultUserSettings ) ); }
[ "private", "function", "loadUsersSettings", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "usersSettings", ")", "{", "return", ";", "}", "$", "this", "->", "usersSettings", "=", "array_replace", "(", "self", "::", "$", "defaultUserSettings", ...
Merge default user settings and configuration customisation.
[ "Merge", "default", "user", "settings", "and", "configuration", "customisation", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php#L135-L149
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php
ThesaurusController.acceptXml
public function acceptXml(Request $request) { $ret = new \DOMDocument("1.0", "UTF-8"); $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "id" => $request->get('id'), "piv" => $request->get('piv'), ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); } try { /** @var \databox $databox */ $databox = $this->findDataboxById((int) $bid); $databox->get_connection()->connect(); $dom = $databox->get_dom_cterms(); $xpath = new \DOMXPath($dom); $q = "/cterms//te[@id='" . $request->get('id') . "']"; /** @var \DOMElement $te */ $te = $xpath->query($q)->item(0); if ($te) { $this->acceptBranch($bid, $te); $databox->saveCterms($dom); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); /** @var \DOMElement $p */ $p = $te->parentNode; $r->setAttribute("id", $p->getAttribute("id")); $r->setAttribute("type", "CT"); } } catch (\Exception $e) { } return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); }
php
public function acceptXml(Request $request) { $ret = new \DOMDocument("1.0", "UTF-8"); $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "id" => $request->get('id'), "piv" => $request->get('piv'), ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); } try { /** @var \databox $databox */ $databox = $this->findDataboxById((int) $bid); $databox->get_connection()->connect(); $dom = $databox->get_dom_cterms(); $xpath = new \DOMXPath($dom); $q = "/cterms//te[@id='" . $request->get('id') . "']"; /** @var \DOMElement $te */ $te = $xpath->query($q)->item(0); if ($te) { $this->acceptBranch($bid, $te); $databox->saveCterms($dom); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); /** @var \DOMElement $p */ $p = $te->parentNode; $r->setAttribute("id", $p->getAttribute("id")); $r->setAttribute("type", "CT"); } } catch (\Exception $e) { } return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); }
[ "public", "function", "acceptXml", "(", "Request", "$", "request", ")", "{", "$", "ret", "=", "new", "\\", "DOMDocument", "(", "\"1.0\"", ",", "\"UTF-8\"", ")", ";", "$", "ret", "->", "preserveWhiteSpace", "=", "false", ";", "$", "root", "=", "$", "ret...
@param Request $request @return Response rétablit un terme candidat rejeté (R) et tous ses enfants comme candidat (C) appelé par le menu contextuel sur candidat / kcterm_accept
[ "@param", "Request", "$request", "@return", "Response" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php#L1233-L1279
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php
ThesaurusController.acceptBranch
private function acceptBranch($sbas_id, \DOMElement $node) { if (strlen($oldid = $node->getAttribute("id")) > 1) { $node->setAttribute("id", $newid = ("C" . substr($oldid, 1))); } for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeType == XML_ELEMENT_NODE) { $this->acceptBranch($sbas_id, $n); } } }
php
private function acceptBranch($sbas_id, \DOMElement $node) { if (strlen($oldid = $node->getAttribute("id")) > 1) { $node->setAttribute("id", $newid = ("C" . substr($oldid, 1))); } for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeType == XML_ELEMENT_NODE) { $this->acceptBranch($sbas_id, $n); } } }
[ "private", "function", "acceptBranch", "(", "$", "sbas_id", ",", "\\", "DOMElement", "$", "node", ")", "{", "if", "(", "strlen", "(", "$", "oldid", "=", "$", "node", "->", "getAttribute", "(", "\"id\"", ")", ")", ">", "1", ")", "{", "$", "node", "-...
transforme (R)ejected en (C)andidate sur un node et tous ses enfants @param $sbas_id @param \DOMElement $node
[ "transforme", "(", "R", ")", "ejected", "en", "(", "C", ")", "andidate", "sur", "un", "node", "et", "tous", "ses", "enfants" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php#L1286-L1296
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php
ThesaurusController.removeSynonymXml
public function removeSynonymXml(Request $request) { $ret = new \DOMDocument("1.0", "UTF-8"); $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); } try { $databox = $this->findDataboxById((int) $bid); $domct = $databox->get_dom_cterms(); $dom = $databox->get_dom_thesaurus(); if ($request->get('typ') == "CT") { $xqroot = "cterms"; } else { $xqroot = "thesaurus"; } if ($dom && $domct) { $xpath = new \DOMXPath($dom); $q = "/$xqroot//sy[@id='" . $request->get('id') . "']"; /** @var \DOMElement $sy0 */ $sy0 = $xpath->query($q)->item(0); if ($sy0) { $xpathct = new \DOMXPath($domct); // on cherche la branche 'deleted' dans les cterms $nodes = $xpathct->query("/cterms/te[@delbranch='1']"); if ( ! $nodes || ($nodes->length == 0)) { // 'deleted' n'existe pas, on la cree $id = $domct->documentElement->getAttribute("nextid"); $domct->documentElement->setAttribute("nextid", (int) ($id) + 1); /** @var \DOMElement $del */ $del = $domct->documentElement->appendChild($domct->createElement("te")); $del->setAttribute("id", "C" . $id); $del->setAttribute("field", $this->app->trans('thesaurus:: corbeille')); $del->setAttribute("nextid", "0"); $del->setAttribute("delbranch", "1"); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", "C"); $r->setAttribute("type", "CT"); } else { // 'deleted' existe /** @var \DOMElement $del */ $del = $nodes->item(0); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", $del->getAttribute("id")); $r->setAttribute("type", "CT"); } // on cree une branche 'te' $refrid = $sy0->parentNode->parentNode->getAttribute("id"); $delid = $del->getAttribute("id"); $delteid = (int) ($del->getAttribute("nextid")); $del->setAttribute("nextid", $delteid + 1); /** @var \DOMElement $delte */ $delte = $del->appendChild($domct->createElement("te")); $delte->setAttribute("id", $delid . "." . $delteid); $delte->setAttribute("nextid", "1"); /** @var \DOMElement $delsy */ $delsy = $delte->appendChild($domct->createElement("sy")); $delsy->setAttribute("id", $newid = ($delid . "." . $delteid . ".0")); $delsy->setAttribute("lng", $sy0->getAttribute("lng")); $delsy->setAttribute("v", $sy0->getAttribute("v")); $delsy->setAttribute("w", $sy0->getAttribute("w")); if ($sy0->hasAttribute("k")) { $delsy->setAttribute("k", $sy0->getAttribute("k")); } $te = $sy0->parentNode; $te->removeChild($sy0); $databox->saveCterms($domct); if ($request->get('typ') == "CT") { $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("type", "CT"); if ($refrid) { $r->setAttribute("id", $refrid); } else { $r->setAttribute("id", "C"); } } else { $databox->saveThesaurus($dom); $this->dispatch( ThesaurusEvents::SYNONYM_TRASHED, new ThesaurusEvent\ItemTrashed($databox, $te->getAttribute('id'), $delsy->getAttribute('id')) ); $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("type", "TH"); if ($refrid) { $r->setAttribute("id", $refrid); } else { $r->setAttribute("id", "T"); } } $ret2 = $this->getXMLTerm( $request->get('bid'), $te->getAttribute("id"), $request->get('typ'), $request->get('piv'), null, null, '1', null ); if ($sl = $ret2->getElementsByTagName("sy_list")->item(0)) { $ret->importNode($sl, true); } } } } catch (\Exception $e) { } return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); }
php
public function removeSynonymXml(Request $request) { $ret = new \DOMDocument("1.0", "UTF-8"); $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); } try { $databox = $this->findDataboxById((int) $bid); $domct = $databox->get_dom_cterms(); $dom = $databox->get_dom_thesaurus(); if ($request->get('typ') == "CT") { $xqroot = "cterms"; } else { $xqroot = "thesaurus"; } if ($dom && $domct) { $xpath = new \DOMXPath($dom); $q = "/$xqroot//sy[@id='" . $request->get('id') . "']"; /** @var \DOMElement $sy0 */ $sy0 = $xpath->query($q)->item(0); if ($sy0) { $xpathct = new \DOMXPath($domct); // on cherche la branche 'deleted' dans les cterms $nodes = $xpathct->query("/cterms/te[@delbranch='1']"); if ( ! $nodes || ($nodes->length == 0)) { // 'deleted' n'existe pas, on la cree $id = $domct->documentElement->getAttribute("nextid"); $domct->documentElement->setAttribute("nextid", (int) ($id) + 1); /** @var \DOMElement $del */ $del = $domct->documentElement->appendChild($domct->createElement("te")); $del->setAttribute("id", "C" . $id); $del->setAttribute("field", $this->app->trans('thesaurus:: corbeille')); $del->setAttribute("nextid", "0"); $del->setAttribute("delbranch", "1"); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", "C"); $r->setAttribute("type", "CT"); } else { // 'deleted' existe /** @var \DOMElement $del */ $del = $nodes->item(0); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", $del->getAttribute("id")); $r->setAttribute("type", "CT"); } // on cree une branche 'te' $refrid = $sy0->parentNode->parentNode->getAttribute("id"); $delid = $del->getAttribute("id"); $delteid = (int) ($del->getAttribute("nextid")); $del->setAttribute("nextid", $delteid + 1); /** @var \DOMElement $delte */ $delte = $del->appendChild($domct->createElement("te")); $delte->setAttribute("id", $delid . "." . $delteid); $delte->setAttribute("nextid", "1"); /** @var \DOMElement $delsy */ $delsy = $delte->appendChild($domct->createElement("sy")); $delsy->setAttribute("id", $newid = ($delid . "." . $delteid . ".0")); $delsy->setAttribute("lng", $sy0->getAttribute("lng")); $delsy->setAttribute("v", $sy0->getAttribute("v")); $delsy->setAttribute("w", $sy0->getAttribute("w")); if ($sy0->hasAttribute("k")) { $delsy->setAttribute("k", $sy0->getAttribute("k")); } $te = $sy0->parentNode; $te->removeChild($sy0); $databox->saveCterms($domct); if ($request->get('typ') == "CT") { $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("type", "CT"); if ($refrid) { $r->setAttribute("id", $refrid); } else { $r->setAttribute("id", "C"); } } else { $databox->saveThesaurus($dom); $this->dispatch( ThesaurusEvents::SYNONYM_TRASHED, new ThesaurusEvent\ItemTrashed($databox, $te->getAttribute('id'), $delsy->getAttribute('id')) ); $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("type", "TH"); if ($refrid) { $r->setAttribute("id", $refrid); } else { $r->setAttribute("id", "T"); } } $ret2 = $this->getXMLTerm( $request->get('bid'), $te->getAttribute("id"), $request->get('typ'), $request->get('piv'), null, null, '1', null ); if ($sl = $ret2->getElementsByTagName("sy_list")->item(0)) { $ret->importNode($sl, true); } } } } catch (\Exception $e) { } return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); }
[ "public", "function", "removeSynonymXml", "(", "Request", "$", "request", ")", "{", "$", "ret", "=", "new", "\\", "DOMDocument", "(", "\"1.0\"", ",", "\"UTF-8\"", ")", ";", "$", "ret", "->", "preserveWhiteSpace", "=", "false", ";", "$", "root", "=", "$",...
supprime un synonyme appelé par le menu contextuel sur un synonyme, option "delete_sy" dans le dialog des properties sur un terme (properties.html.twig) @param Request $request @return Response
[ "supprime", "un", "synonyme", "appelé", "par", "le", "menu", "contextuel", "sur", "un", "synonyme", "option", "delete_sy", "dans", "le", "dialog", "des", "properties", "sur", "un", "terme", "(", "properties", ".", "html", ".", "twig", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php#L1629-L1767
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php
ThesaurusController.removeSpecificTermXml
public function removeSpecificTermXml(Request $request) { $ret = new \DOMDocument("1.0", "UTF-8"); $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); } try { /** @var \databox $databox */ $databox = $this->findDataboxById((int) $bid); $domth = $databox->get_dom_thesaurus(); $domct = $databox->get_dom_cterms(); if ($domth && $domct) { $xpathth = new \DOMXPath($domth); $xpathct = new \DOMXPath($domct); if ($request->get('id') !== "") { // secu pour pas exploser le thesaurus $q = "/thesaurus//te[@id='" . $request->get('id') . "']"; $thnode = $xpathth->query($q)->item(0); if ($thnode) { /** @var \DOMElement $thnode_parent */ $thnode_parent = $thnode->parentNode; $chgids = []; $pid = $thnode_parent->getAttribute("id"); if ($pid === "") { $pid = "T"; } $nodes = $xpathct->query("/cterms/te[@delbranch='1']"); if ( ! $nodes || ($nodes->length == 0)) { $id = $domct->documentElement->getAttribute("nextid"); $domct->documentElement->setAttribute("nextid", (int) ($id) + 1); /** @var \DOMElement $ct */ $ct = $domct->documentElement->appendChild($domct->createElement("te")); $ct->setAttribute("id", "C" . $id); $ct->setAttribute("field", $this->app->trans('thesaurus:: corbeille')); $ct->setAttribute("nextid", "0"); $ct->setAttribute("delbranch", "1"); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", "C"); $r->setAttribute("type", "CT"); } else { /** @var \DOMElement $ct */ $ct = $nodes->item(0); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", $ct->getAttribute("id")); $r->setAttribute("type", "CT"); } $teid = (int) ($ct->getAttribute("nextid")); $ct->setAttribute("nextid", $teid + 1); /** @var \DOMElement $newte */ $newte = $ct->appendChild($domct->importNode($thnode, true)); $this->renumerate($newte, $ct->getAttribute("id") . "." . $teid, $chgids); $databox->saveCterms($domct); $this->dispatch( ThesaurusEvents::CONCEPT_TRASHED, new ThesaurusEvent\ItemTrashed($databox, $thnode_parent->getAttribute('id'), $newte->getAttribute('id')) ); $thnode_parent->removeChild($thnode); $databox->saveThesaurus($domth); $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", $pid); $r->setAttribute("type", "TH"); } } } } catch (\Exception $e) { } return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); }
php
public function removeSpecificTermXml(Request $request) { $ret = new \DOMDocument("1.0", "UTF-8"); $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); } try { /** @var \databox $databox */ $databox = $this->findDataboxById((int) $bid); $domth = $databox->get_dom_thesaurus(); $domct = $databox->get_dom_cterms(); if ($domth && $domct) { $xpathth = new \DOMXPath($domth); $xpathct = new \DOMXPath($domct); if ($request->get('id') !== "") { // secu pour pas exploser le thesaurus $q = "/thesaurus//te[@id='" . $request->get('id') . "']"; $thnode = $xpathth->query($q)->item(0); if ($thnode) { /** @var \DOMElement $thnode_parent */ $thnode_parent = $thnode->parentNode; $chgids = []; $pid = $thnode_parent->getAttribute("id"); if ($pid === "") { $pid = "T"; } $nodes = $xpathct->query("/cterms/te[@delbranch='1']"); if ( ! $nodes || ($nodes->length == 0)) { $id = $domct->documentElement->getAttribute("nextid"); $domct->documentElement->setAttribute("nextid", (int) ($id) + 1); /** @var \DOMElement $ct */ $ct = $domct->documentElement->appendChild($domct->createElement("te")); $ct->setAttribute("id", "C" . $id); $ct->setAttribute("field", $this->app->trans('thesaurus:: corbeille')); $ct->setAttribute("nextid", "0"); $ct->setAttribute("delbranch", "1"); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", "C"); $r->setAttribute("type", "CT"); } else { /** @var \DOMElement $ct */ $ct = $nodes->item(0); /** @var \DOMElement $r */ $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", $ct->getAttribute("id")); $r->setAttribute("type", "CT"); } $teid = (int) ($ct->getAttribute("nextid")); $ct->setAttribute("nextid", $teid + 1); /** @var \DOMElement $newte */ $newte = $ct->appendChild($domct->importNode($thnode, true)); $this->renumerate($newte, $ct->getAttribute("id") . "." . $teid, $chgids); $databox->saveCterms($domct); $this->dispatch( ThesaurusEvents::CONCEPT_TRASHED, new ThesaurusEvent\ItemTrashed($databox, $thnode_parent->getAttribute('id'), $newte->getAttribute('id')) ); $thnode_parent->removeChild($thnode); $databox->saveThesaurus($domth); $r = $refresh_list->appendChild($ret->createElement("refresh")); $r->setAttribute("id", $pid); $r->setAttribute("type", "TH"); } } } } catch (\Exception $e) { } return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); }
[ "public", "function", "removeSpecificTermXml", "(", "Request", "$", "request", ")", "{", "$", "ret", "=", "new", "\\", "DOMDocument", "(", "\"1.0\"", ",", "\"UTF-8\"", ")", ";", "$", "ret", "->", "preserveWhiteSpace", "=", "false", ";", "$", "root", "=", ...
Supprime (déplace dans cterms/trash) toute une branche TE avec les SY et tous les TE enfants appelé par le menu contextuel sur terme, option "kterm_delete" @param Request $request @return Response
[ "Supprime", "(", "déplace", "dans", "cterms", "/", "trash", ")", "toute", "une", "branche", "TE", "avec", "les", "SY", "et", "tous", "les", "TE", "enfants", "appelé", "par", "le", "menu", "contextuel", "sur", "terme", "option", "kterm_delete" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php#L1775-L1869
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php
ThesaurusController.buildSynonymFromSy
private function buildSynonymFromSy(\DOMElement $sy) { if($sy->nodeName == 'sy') { return new ThesaurusEvent\SynonymParm($sy->getAttribute('v'), $sy->getAttribute('lng')); } return null; }
php
private function buildSynonymFromSy(\DOMElement $sy) { if($sy->nodeName == 'sy') { return new ThesaurusEvent\SynonymParm($sy->getAttribute('v'), $sy->getAttribute('lng')); } return null; }
[ "private", "function", "buildSynonymFromSy", "(", "\\", "DOMElement", "$", "sy", ")", "{", "if", "(", "$", "sy", "->", "nodeName", "==", "'sy'", ")", "{", "return", "new", "ThesaurusEvent", "\\", "SynonymParm", "(", "$", "sy", "->", "getAttribute", "(", ...
@param \DOMElement $sy @return ThesaurusEvent\SynonymParm|null helper to build event parameter
[ "@param", "\\", "DOMElement", "$sy", "@return", "ThesaurusEvent", "\\", "SynonymParm|null" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php#L2991-L2997
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php
ThesaurusController.buildSynonymsFromTe
private function buildSynonymsFromTe(\DOMElement $te) { $ret = array(); if(strtolower($te->nodeName) == 'te') { foreach ($te->childNodes as $child) { if($child->nodeType == XML_ELEMENT_NODE && $child->nodeName == 'sy') { $ret[] = $this->buildSynonymFromSy($child); } } return $ret; } return null; }
php
private function buildSynonymsFromTe(\DOMElement $te) { $ret = array(); if(strtolower($te->nodeName) == 'te') { foreach ($te->childNodes as $child) { if($child->nodeType == XML_ELEMENT_NODE && $child->nodeName == 'sy') { $ret[] = $this->buildSynonymFromSy($child); } } return $ret; } return null; }
[ "private", "function", "buildSynonymsFromTe", "(", "\\", "DOMElement", "$", "te", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "if", "(", "strtolower", "(", "$", "te", "->", "nodeName", ")", "==", "'te'", ")", "{", "foreach", "(", "$", "te", ...
@param \DOMElement $te @return array|null helper to build event parameter
[ "@param", "\\", "DOMElement", "$te", "@return", "array|null" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusController.php#L3005-L3017
alchemy-fr/Phraseanet
lib/classes/patch/380alpha16a.php
patch_380alpha16a.apply
public function apply(base $appbox, Application $app) { $xsendfile = $app['conf']->get('xsendfile'); if (!isset($xsendfile['mapping'])) { $xsendfile['mapping'] = []; } $xsendfile['mapping'][] = [ 'directory' => $app['tmp.lazaret.path'], 'mount-point' => '/lazaret/', ]; $xsendfile['mapping'][] = [ 'directory' => $app['tmp.download.path'], 'mount-point' => '/download/', ]; $app['conf']->set('xsendfile', $xsendfile); return true; }
php
public function apply(base $appbox, Application $app) { $xsendfile = $app['conf']->get('xsendfile'); if (!isset($xsendfile['mapping'])) { $xsendfile['mapping'] = []; } $xsendfile['mapping'][] = [ 'directory' => $app['tmp.lazaret.path'], 'mount-point' => '/lazaret/', ]; $xsendfile['mapping'][] = [ 'directory' => $app['tmp.download.path'], 'mount-point' => '/download/', ]; $app['conf']->set('xsendfile', $xsendfile); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "xsendfile", "=", "$", "app", "[", "'conf'", "]", "->", "get", "(", "'xsendfile'", ")", ";", "if", "(", "!", "isset", "(", "$", "xsendfile", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/380alpha16a.php#L49-L69
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/MailRequestAccountDelete.php
MailRequestAccountDelete.getMessage
public function getMessage() { if (!$this->user) { throw new LogicException('You must set a user before calling getMessage'); } return $this->app->trans("Email:deletion:request:message Hello %civility% %firstName% %lastName%. We have received an account deletion request for your account on %urlInstance%, please confirm this deletion by clicking on the link below. If you are not at the origin of this request, please change your password as soon as possible %resetPassword% Link is valid for one hour.", [ '%civility%' => $this->getOwnerCivility(), '%firstName%'=> $this->user->getFirstName(), '%lastName%' => $this->user->getLastName(), '%urlInstance%' => '<a href="'.$this->getPhraseanetURL().'">'.$this->getPhraseanetURL().'</a>', '%resetPassword%' => '<a href="'.$this->app->url('reset_password').'">'.$this->app->url('reset_password').'</a>', ]); }
php
public function getMessage() { if (!$this->user) { throw new LogicException('You must set a user before calling getMessage'); } return $this->app->trans("Email:deletion:request:message Hello %civility% %firstName% %lastName%. We have received an account deletion request for your account on %urlInstance%, please confirm this deletion by clicking on the link below. If you are not at the origin of this request, please change your password as soon as possible %resetPassword% Link is valid for one hour.", [ '%civility%' => $this->getOwnerCivility(), '%firstName%'=> $this->user->getFirstName(), '%lastName%' => $this->user->getLastName(), '%urlInstance%' => '<a href="'.$this->getPhraseanetURL().'">'.$this->getPhraseanetURL().'</a>', '%resetPassword%' => '<a href="'.$this->app->url('reset_password').'">'.$this->app->url('reset_password').'</a>', ]); }
[ "public", "function", "getMessage", "(", ")", "{", "if", "(", "!", "$", "this", "->", "user", ")", "{", "throw", "new", "LogicException", "(", "'You must set a user before calling getMessage'", ")", ";", "}", "return", "$", "this", "->", "app", "->", "trans"...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailRequestAccountDelete.php#L45-L61
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.last_model_is
public function last_model_is($login = null) { $this->last_model = $login instanceof User ? $login->getId() : $login; return $this; }
php
public function last_model_is($login = null) { $this->last_model = $login instanceof User ? $login->getId() : $login; return $this; }
[ "public", "function", "last_model_is", "(", "$", "login", "=", "null", ")", "{", "$", "this", "->", "last_model", "=", "$", "login", "instanceof", "User", "?", "$", "login", "->", "getId", "(", ")", ":", "$", "login", ";", "return", "$", "this", ";",...
Restrict user with the provided last model @param User|int|null $login @return $this
[ "Restrict", "user", "with", "the", "provided", "last", "model" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L117-L122
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.execute
public function execute() { $conn = $this->app->getApplicationBox()->get_connection(); list ($sql, $params) = $this->createSelectQuery(); if (is_int($this->offset_start) && is_int($this->results_quantity)) { $sql .= sprintf( ' LIMIT %d, %d' , $this->offset_start , $this->results_quantity ); } $stmt = $conn->prepare($sql); $stmt->execute($params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $userIndexes = []; foreach ($rs as $index => $row) { $userIndexes[$row['id']] = $index; } $users = []; /** @var User $user */ foreach ($this->app['repo.users']->findBy(['id' => array_keys($userIndexes)]) as $user) { $users[$userIndexes[$user->getId()]] = $user; } ksort($users); $this->results = new ArrayCollection($users); return $this; }
php
public function execute() { $conn = $this->app->getApplicationBox()->get_connection(); list ($sql, $params) = $this->createSelectQuery(); if (is_int($this->offset_start) && is_int($this->results_quantity)) { $sql .= sprintf( ' LIMIT %d, %d' , $this->offset_start , $this->results_quantity ); } $stmt = $conn->prepare($sql); $stmt->execute($params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $userIndexes = []; foreach ($rs as $index => $row) { $userIndexes[$row['id']] = $index; } $users = []; /** @var User $user */ foreach ($this->app['repo.users']->findBy(['id' => array_keys($userIndexes)]) as $user) { $users[$userIndexes[$user->getId()]] = $user; } ksort($users); $this->results = new ArrayCollection($users); return $this; }
[ "public", "function", "execute", "(", ")", "{", "$", "conn", "=", "$", "this", "->", "app", "->", "getApplicationBox", "(", ")", "->", "get_connection", "(", ")", ";", "list", "(", "$", "sql", ",", "$", "params", ")", "=", "$", "this", "->", "creat...
Execute query @return $this
[ "Execute", "query" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L241-L277
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.get_total
public function get_total() { if ($this->total) { return $this->total; } $conn = $this->app->getApplicationBox()->get_connection(); $sql_count = 'SELECT COUNT(DISTINCT Users.id) as total ' . $this->generate_sql_constraints(); $stmt = $conn->prepare($sql_count); $stmt->execute($this->sql_params); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->total = $row['total']; $this->page = 1; if ($this->total > 0 && is_int($this->offset_start) && is_int($this->results_quantity)) { $this->page = floor($this->offset_start / $this->results_quantity) + 1; $this->total_page = floor($this->total / $this->results_quantity) + 1; } return $this->total; }
php
public function get_total() { if ($this->total) { return $this->total; } $conn = $this->app->getApplicationBox()->get_connection(); $sql_count = 'SELECT COUNT(DISTINCT Users.id) as total ' . $this->generate_sql_constraints(); $stmt = $conn->prepare($sql_count); $stmt->execute($this->sql_params); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->total = $row['total']; $this->page = 1; if ($this->total > 0 && is_int($this->offset_start) && is_int($this->results_quantity)) { $this->page = floor($this->offset_start / $this->results_quantity) + 1; $this->total_page = floor($this->total / $this->results_quantity) + 1; } return $this->total; }
[ "public", "function", "get_total", "(", ")", "{", "if", "(", "$", "this", "->", "total", ")", "{", "return", "$", "this", "->", "total", ";", "}", "$", "conn", "=", "$", "this", "->", "app", "->", "getApplicationBox", "(", ")", "->", "get_connection"...
Get total of fetched users @return int
[ "Get", "total", "of", "fetched", "users" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L284-L308
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.on_bases_where_i_am
public function on_bases_where_i_am(ACL $ACL, Array $rights) { $this->bases_restrictions = true; $collections = array_keys($ACL->get_granted_base($rights)); if (count($this->base_ids) > 0) { $this->base_ids = array_intersect($this->base_ids, $collections); } else { $this->base_ids = $collections; } $this->total = $this->page = $this->total_page = null; return $this; }
php
public function on_bases_where_i_am(ACL $ACL, Array $rights) { $this->bases_restrictions = true; $collections = array_keys($ACL->get_granted_base($rights)); if (count($this->base_ids) > 0) { $this->base_ids = array_intersect($this->base_ids, $collections); } else { $this->base_ids = $collections; } $this->total = $this->page = $this->total_page = null; return $this; }
[ "public", "function", "on_bases_where_i_am", "(", "ACL", "$", "ACL", ",", "Array", "$", "rights", ")", "{", "$", "this", "->", "bases_restrictions", "=", "true", ";", "$", "collections", "=", "array_keys", "(", "$", "ACL", "->", "get_granted_base", "(", "$...
Restrict users on collection with provided rights @param ACL $ACL @param array $rights @return $this
[ "Restrict", "users", "on", "collection", "with", "provided", "rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L342-L356
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.on_sbas_where_i_am
public function on_sbas_where_i_am(ACL $ACL, Array $rights) { $this->sbas_restrictions = true; $databoxes = array_keys($ACL->get_granted_sbas($rights)); if (count($this->sbas_ids) > 0) $this->sbas_ids = array_intersect($this->sbas_ids, $databoxes); else $this->sbas_ids = $databoxes; $this->total = $this->page = $this->total_page = null; return $this; }
php
public function on_sbas_where_i_am(ACL $ACL, Array $rights) { $this->sbas_restrictions = true; $databoxes = array_keys($ACL->get_granted_sbas($rights)); if (count($this->sbas_ids) > 0) $this->sbas_ids = array_intersect($this->sbas_ids, $databoxes); else $this->sbas_ids = $databoxes; $this->total = $this->page = $this->total_page = null; return $this; }
[ "public", "function", "on_sbas_where_i_am", "(", "ACL", "$", "ACL", ",", "Array", "$", "rights", ")", "{", "$", "this", "->", "sbas_restrictions", "=", "true", ";", "$", "databoxes", "=", "array_keys", "(", "$", "ACL", "->", "get_granted_sbas", "(", "$", ...
Restrict users on database with provided rights @param ACL $ACL @param array $rights @return $this
[ "Restrict", "users", "on", "database", "with", "provided", "rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L366-L379
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.limit
public function limit($offset_start, $results_quantity) { $this->offset_start = (int) $offset_start; $this->results_quantity = (int) $results_quantity; return $this; }
php
public function limit($offset_start, $results_quantity) { $this->offset_start = (int) $offset_start; $this->results_quantity = (int) $results_quantity; return $this; }
[ "public", "function", "limit", "(", "$", "offset_start", ",", "$", "results_quantity", ")", "{", "$", "this", "->", "offset_start", "=", "(", "int", ")", "$", "offset_start", ";", "$", "this", "->", "results_quantity", "=", "(", "int", ")", "$", "results...
Restrict to provided limits @param $offset_start @param $results_quantity @return $this
[ "Restrict", "to", "provided", "limits" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L389-L395
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.like
public function like($like_field, $like_value) { $this->like_field[trim($like_field)] = trim($like_value); $this->total = $this->page = $this->total_page = null; return $this; }
php
public function like($like_field, $like_value) { $this->like_field[trim($like_field)] = trim($like_value); $this->total = $this->page = $this->total_page = null; return $this; }
[ "public", "function", "like", "(", "$", "like_field", ",", "$", "like_value", ")", "{", "$", "this", "->", "like_field", "[", "trim", "(", "$", "like_field", ")", "]", "=", "trim", "(", "$", "like_value", ")", ";", "$", "this", "->", "total", "=", ...
Restrict on provided field with provided value @param $like_field @param $like_value @return $this
[ "Restrict", "on", "provided", "field", "with", "provided", "value" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L405-L411
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.like_match
public function like_match($like_match) { switch ($like_match) { case self::LIKE_MATCH_AND: case self::LIKE_MATCH_OR: $this->like_match = $like_match; break; default: break; } $this->total = $this->page = $this->total_page = null; return $this; }
php
public function like_match($like_match) { switch ($like_match) { case self::LIKE_MATCH_AND: case self::LIKE_MATCH_OR: $this->like_match = $like_match; break; default: break; } $this->total = $this->page = $this->total_page = null; return $this; }
[ "public", "function", "like_match", "(", "$", "like_match", ")", "{", "switch", "(", "$", "like_match", ")", "{", "case", "self", "::", "LIKE_MATCH_AND", ":", "case", "self", "::", "LIKE_MATCH_OR", ":", "$", "this", "->", "like_match", "=", "$", "like_matc...
Restrict on match @param $like_match @return $this
[ "Restrict", "on", "match" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L420-L433
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.on_base_ids
public function on_base_ids(array $base_ids = null) { if (! $base_ids) { return $this; } $this->bases_restrictions = true; $this->include_phantoms(false); if (count($this->base_ids) > 0) { $this->base_ids = array_intersect($this->base_ids, $base_ids); } else { $this->base_ids = $base_ids; } $this->total = $this->page = $this->total_page = null; return $this; }
php
public function on_base_ids(array $base_ids = null) { if (! $base_ids) { return $this; } $this->bases_restrictions = true; $this->include_phantoms(false); if (count($this->base_ids) > 0) { $this->base_ids = array_intersect($this->base_ids, $base_ids); } else { $this->base_ids = $base_ids; } $this->total = $this->page = $this->total_page = null; return $this; }
[ "public", "function", "on_base_ids", "(", "array", "$", "base_ids", "=", "null", ")", "{", "if", "(", "!", "$", "base_ids", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "bases_restrictions", "=", "true", ";", "$", "this", "->", "incl...
Restrict on collections @param array $base_ids @return $this
[ "Restrict", "on", "collections" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L442-L461
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.on_sbas_ids
public function on_sbas_ids(Array $sbas_ids = null) { if (! $sbas_ids) { return $this; } $this->sbas_restrictions = true; $this->include_phantoms(false); if (count($this->sbas_ids) > 0) { $this->sbas_ids = array_intersect($this->sbas_ids, $sbas_ids); } else { $this->sbas_ids = $sbas_ids; } $this->total = $this->page = $this->total_page = null; return $this; }
php
public function on_sbas_ids(Array $sbas_ids = null) { if (! $sbas_ids) { return $this; } $this->sbas_restrictions = true; $this->include_phantoms(false); if (count($this->sbas_ids) > 0) { $this->sbas_ids = array_intersect($this->sbas_ids, $sbas_ids); } else { $this->sbas_ids = $sbas_ids; } $this->total = $this->page = $this->total_page = null; return $this; }
[ "public", "function", "on_sbas_ids", "(", "Array", "$", "sbas_ids", "=", "null", ")", "{", "if", "(", "!", "$", "sbas_ids", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "sbas_restrictions", "=", "true", ";", "$", "this", "->", "inclu...
Restrict on databoxes @param array $sbas_ids @return $this
[ "Restrict", "on", "databoxes" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L470-L489
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.sort_by
public function sort_by($sort, $ord = self::ORD_ASC) { $this->sort[$sort] = $ord; return $this; }
php
public function sort_by($sort, $ord = self::ORD_ASC) { $this->sort[$sort] = $ord; return $this; }
[ "public", "function", "sort_by", "(", "$", "sort", ",", "$", "ord", "=", "self", "::", "ORD_ASC", ")", "{", "$", "this", "->", "sort", "[", "$", "sort", "]", "=", "$", "ord", ";", "return", "$", "this", ";", "}" ]
Sort by @param $sort @param string $ord @return $this
[ "Sort", "by" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L499-L504
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.haveActivities
public function haveActivities(array $req_activities) { $activities = new ArrayCollection(); foreach ($req_activities as $activity) { if ($activity = trim($activity) === '') { continue; } if ($activities->contains($activity)) { continue; } $activities->add($activity); } if (!$activities->isEmpty()) { $this->activities = $activities; } return $this; }
php
public function haveActivities(array $req_activities) { $activities = new ArrayCollection(); foreach ($req_activities as $activity) { if ($activity = trim($activity) === '') { continue; } if ($activities->contains($activity)) { continue; } $activities->add($activity); } if (!$activities->isEmpty()) { $this->activities = $activities; } return $this; }
[ "public", "function", "haveActivities", "(", "array", "$", "req_activities", ")", "{", "$", "activities", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "req_activities", "as", "$", "activity", ")", "{", "if", "(", "$", "activity", "=",...
Restrict users with provided activities @param array $req_activities @return $this
[ "Restrict", "users", "with", "provided", "activities" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L513-L534
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.havePositions
public function havePositions(array $req_positions) { $positions = new ArrayCollection(); foreach ($req_positions as $position) { if ($position = trim($position) === '') { continue; } if ($positions->contains($position)) { continue; } $positions->add($position); } if (!$positions->isEmpty()) { $this->positions = $positions; } return $this; }
php
public function havePositions(array $req_positions) { $positions = new ArrayCollection(); foreach ($req_positions as $position) { if ($position = trim($position) === '') { continue; } if ($positions->contains($position)) { continue; } $positions->add($position); } if (!$positions->isEmpty()) { $this->positions = $positions; } return $this; }
[ "public", "function", "havePositions", "(", "array", "$", "req_positions", ")", "{", "$", "positions", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "req_positions", "as", "$", "position", ")", "{", "if", "(", "$", "position", "=", "...
Restrict users with provided jobs @param array $req_positions @return $this
[ "Restrict", "users", "with", "provided", "jobs" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L543-L563
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.inCountries
public function inCountries(array $req_countries) { $countries = new ArrayCollection(); foreach ($req_countries as $country) { if ($country = trim($country) === '') { continue; } if ($countries->contains($country)) { continue; } $countries->add($country); } if (!$countries->isEmpty()) { $this->countries = $countries; } return $this; }
php
public function inCountries(array $req_countries) { $countries = new ArrayCollection(); foreach ($req_countries as $country) { if ($country = trim($country) === '') { continue; } if ($countries->contains($country)) { continue; } $countries->add($country); } if (!$countries->isEmpty()) { $this->countries = $countries; } return $this; }
[ "public", "function", "inCountries", "(", "array", "$", "req_countries", ")", "{", "$", "countries", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "req_countries", "as", "$", "country", ")", "{", "if", "(", "$", "country", "=", "trim...
Restrict users by countries @param array $req_countries @return $this
[ "Restrict", "users", "by", "countries" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L572-L592
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.inCompanies
public function inCompanies(array $req_companies) { $companies = new ArrayCollection(); foreach ($req_companies as $company) { if ($company = trim($company) === '') { continue; } if ($companies->contains($company)) { continue; } $companies->add($company); } if (!$companies->isEmpty()) { $this->companies = $companies; } return $this; }
php
public function inCompanies(array $req_companies) { $companies = new ArrayCollection(); foreach ($req_companies as $company) { if ($company = trim($company) === '') { continue; } if ($companies->contains($company)) { continue; } $companies->add($company); } if (!$companies->isEmpty()) { $this->companies = $companies; } return $this; }
[ "public", "function", "inCompanies", "(", "array", "$", "req_companies", ")", "{", "$", "companies", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "req_companies", "as", "$", "company", ")", "{", "if", "(", "$", "company", "=", "trim...
Restrict users by companies @param array $req_companies @return $this
[ "Restrict", "users", "by", "companies" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L601-L620
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.haveTemplate
public function haveTemplate(array $req_templates) { $templates = new ArrayCollection(); foreach ($req_templates as $template) { if ($template = trim($template) === '') { continue; } if ($templates->contains($template)) { continue; } $templates->add($template); } if (!$templates->isEmpty()) { $this->templates = $templates; } return $this; }
php
public function haveTemplate(array $req_templates) { $templates = new ArrayCollection(); foreach ($req_templates as $template) { if ($template = trim($template) === '') { continue; } if ($templates->contains($template)) { continue; } $templates->add($template); } if (!$templates->isEmpty()) { $this->templates = $templates; } return $this; }
[ "public", "function", "haveTemplate", "(", "array", "$", "req_templates", ")", "{", "$", "templates", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "req_templates", "as", "$", "template", ")", "{", "if", "(", "$", "template", "=", "t...
Restrict users with given templates @param array $req_templates @return $this
[ "Restrict", "users", "with", "given", "templates" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L629-L648
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.getRelatedCountries
public function getRelatedCountries() { $conn = $this->app->getApplicationBox()->get_connection(); $sql = 'SELECT DISTINCT Users.country ' . $this->generate_sql_constraints() . ' ORDER BY Users.country'; $stmt = $conn->prepare($sql); $stmt->execute($this->sql_params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $countries = []; $listCountry = Countries::getCountries($this->app['locale']); foreach ($rs as $row) { if (trim($row['country']) === '') { continue; } if (isset($listCountry[$row['country']])) { $countries[$row['country']] = $listCountry[$row['country']]; } } return $countries; }
php
public function getRelatedCountries() { $conn = $this->app->getApplicationBox()->get_connection(); $sql = 'SELECT DISTINCT Users.country ' . $this->generate_sql_constraints() . ' ORDER BY Users.country'; $stmt = $conn->prepare($sql); $stmt->execute($this->sql_params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $countries = []; $listCountry = Countries::getCountries($this->app['locale']); foreach ($rs as $row) { if (trim($row['country']) === '') { continue; } if (isset($listCountry[$row['country']])) { $countries[$row['country']] = $listCountry[$row['country']]; } } return $countries; }
[ "public", "function", "getRelatedCountries", "(", ")", "{", "$", "conn", "=", "$", "this", "->", "app", "->", "getApplicationBox", "(", ")", "->", "get_connection", "(", ")", ";", "$", "sql", "=", "'SELECT DISTINCT Users.country '", ".", "$", "this", "->", ...
Get user countries @return array
[ "Get", "user", "countries" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L724-L748
alchemy-fr/Phraseanet
lib/classes/User/Query.php
User_Query.getRelatedCompanies
public function getRelatedCompanies() { $conn = $this->app->getApplicationBox()->get_connection(); $sql = 'SELECT DISTINCT Users.company ' . $this->generate_sql_constraints() . ' ORDER BY Users.company'; $stmt = $conn->prepare($sql); $stmt->execute($this->sql_params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $companies = []; foreach ($rs as $row) { if (trim($row['company']) === '') { continue; } $companies[] = $row['company']; } return $companies; }
php
public function getRelatedCompanies() { $conn = $this->app->getApplicationBox()->get_connection(); $sql = 'SELECT DISTINCT Users.company ' . $this->generate_sql_constraints() . ' ORDER BY Users.company'; $stmt = $conn->prepare($sql); $stmt->execute($this->sql_params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $companies = []; foreach ($rs as $row) { if (trim($row['company']) === '') { continue; } $companies[] = $row['company']; } return $companies; }
[ "public", "function", "getRelatedCompanies", "(", ")", "{", "$", "conn", "=", "$", "this", "->", "app", "->", "getApplicationBox", "(", ")", "->", "get_connection", "(", ")", ";", "$", "sql", "=", "'SELECT DISTINCT Users.company '", ".", "$", "this", "->", ...
Get users companies @return array
[ "Get", "users", "companies" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/User/Query.php#L755-L775
alchemy-fr/Phraseanet
lib/classes/module/report/dashboard/feed.php
module_report_dashboard_feed.getInstance
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; }
php
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; }
[ "public", "static", "function", "getInstance", "(", "Application", "$", "app", ",", "$", "sbasid", ",", "$", "sbas_coll", ",", "$", "dmin", ",", "$", "dmax", ")", "{", "$", "cache_id", "=", "'feed_'", ".", "md5", "(", "$", "sbasid", ".", "'_'", ".", ...
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
[ "Returns", "l", "objet", "stockee", "dans", "le", "cache", "si", "i", "l", "existe", "sinon", "instancie", "un", "nouveau", "objet", "dashboard_feed" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report/dashboard/feed.php#L71-L88
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Converter/TokenConverter.php
TokenConverter.convert
public function convert($value) { if (null === $token = $this->repository->findValidToken($value)) { throw new NotFoundHttpException('Token is not valid.'); } return $token; }
php
public function convert($value) { if (null === $token = $this->repository->findValidToken($value)) { throw new NotFoundHttpException('Token is not valid.'); } return $token; }
[ "public", "function", "convert", "(", "$", "value", ")", "{", "if", "(", "null", "===", "$", "token", "=", "$", "this", "->", "repository", "->", "findValidToken", "(", "$", "value", ")", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'Token is...
{@inheritdoc} @return Token
[ "{", "@inheritdoc", "}" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Converter/TokenConverter.php#L32-L39
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php
UserRepository.findAdmins
public function findAdmins() { $qb = $this->createQueryBuilder('u'); $qb->where($qb->expr()->eq('u.admin', $qb->expr()->literal(true))) ->andWhere($qb->expr()->isNull('u.templateOwner')) ->andWhere($qb->expr()->eq('u.deleted', $qb->expr()->literal(false))); return $qb->getQuery()->getResult(); }
php
public function findAdmins() { $qb = $this->createQueryBuilder('u'); $qb->where($qb->expr()->eq('u.admin', $qb->expr()->literal(true))) ->andWhere($qb->expr()->isNull('u.templateOwner')) ->andWhere($qb->expr()->eq('u.deleted', $qb->expr()->literal(false))); return $qb->getQuery()->getResult(); }
[ "public", "function", "findAdmins", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'u'", ")", ";", "$", "qb", "->", "where", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'u.admin'", ",", "$", "qb", "->"...
Finds admins. @return User[]
[ "Finds", "admins", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php#L42-L51
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php
UserRepository.findByEmail
public function findByEmail($email) { $qb = $this->createQueryBuilder('u'); $qb->where($qb->expr()->eq($qb->expr()->lower('u.email'), $qb->expr()->lower($qb->expr()->literal($email)))) ->andWhere($qb->expr()->isNotNull('u.email')) ->andWhere($qb->expr()->eq('u.deleted', $qb->expr()->literal(false))); return $qb->getQuery()->getOneOrNullResult(); }
php
public function findByEmail($email) { $qb = $this->createQueryBuilder('u'); $qb->where($qb->expr()->eq($qb->expr()->lower('u.email'), $qb->expr()->lower($qb->expr()->literal($email)))) ->andWhere($qb->expr()->isNotNull('u.email')) ->andWhere($qb->expr()->eq('u.deleted', $qb->expr()->literal(false))); return $qb->getQuery()->getOneOrNullResult(); }
[ "public", "function", "findByEmail", "(", "$", "email", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'u'", ")", ";", "$", "qb", "->", "where", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "$", "qb", "->", ...
Finds a user by email. nb : mail match is CASE INSENSITIVE, "john@doe"=="John@Doe"=="john@DOE" @param string $email @return null|User
[ "Finds", "a", "user", "by", "email", ".", "nb", ":", "mail", "match", "is", "CASE", "INSENSITIVE", "john@doe", "==", "John@Doe", "==", "john@DOE" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php#L83-L92
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php
UserRepository.findRealUserByLogin
public function findRealUserByLogin($login) { $qb = $this->createQueryBuilder('u'); $qb->where($qb->expr()->eq($qb->expr()->lower('u.login'), $qb->expr()->lower($qb->expr()->literal($login)))) ->andWhere($qb->expr()->isNotNull('u.email')) ->andWhere($qb->expr()->isNull('u.templateOwner')) ->andWhere($qb->expr()->eq('u.guest', $qb->expr()->literal(false))) ->andWhere($qb->expr()->eq('u.deleted', $qb->expr()->literal(false))); return $qb->getQuery()->getOneOrNullResult(); }
php
public function findRealUserByLogin($login) { $qb = $this->createQueryBuilder('u'); $qb->where($qb->expr()->eq($qb->expr()->lower('u.login'), $qb->expr()->lower($qb->expr()->literal($login)))) ->andWhere($qb->expr()->isNotNull('u.email')) ->andWhere($qb->expr()->isNull('u.templateOwner')) ->andWhere($qb->expr()->eq('u.guest', $qb->expr()->literal(false))) ->andWhere($qb->expr()->eq('u.deleted', $qb->expr()->literal(false))); return $qb->getQuery()->getOneOrNullResult(); }
[ "public", "function", "findRealUserByLogin", "(", "$", "login", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'u'", ")", ";", "$", "qb", "->", "where", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "$", "qb", ...
Finds a user that is not deleted, not a model and not a guest. nb : login match is CASE INSENSITIVE, "doe"=="Doe"=="DOE" @param $login @return null|User
[ "Finds", "a", "user", "that", "is", "not", "deleted", "not", "a", "model", "and", "not", "a", "guest", ".", "nb", ":", "login", "match", "is", "CASE", "INSENSITIVE", "doe", "==", "Doe", "==", "DOE" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php#L102-L112
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php
ArchiveJob.doJob
protected function doJob(JobData $data) { $app = $data->getApplication(); $task = $data->getTask(); $settings = simplexml_load_string($task->getSettings()); $baseId = (string) $settings->base_id; $sbasId = \phrasea::sbasFromBas($app, $baseId); if (!$sbasId) { throw new RuntimeException('Invalid collection base_id.'); } $databox = $app->findDataboxById($sbasId); $TColls = []; $collection = null; foreach ($databox->get_collections() as $coll) { $TColls['c' . $coll->get_coll_id()] = $coll->get_coll_id(); if ($baseId == $coll->get_base_id()) { $collection = $coll; } } $server_coll_id = $collection->get_coll_id(); // mask(s) of accepted files $tmask = []; $tmaskgrp = []; $cold = min(max((int) $settings->cold, self::MINCOLD), self::MAXCOLD); $stat0 = $stat1 = "0"; if (false !== $sxBasePrefs = simplexml_load_string($collection->get_prefs())) { if ($sxBasePrefs->status) { $stat0 = (string) $sxBasePrefs->status; } } if ($settings->status) { $stat1 = (string) $settings->status; } if (!$stat0) { $stat0 = '0'; } if (!$stat1) { $stat1 = '0'; } $filesystem = $app['filesystem']; // load masks if ($settings->files && $settings->files->file) { foreach ($settings->files->file as $ft) { $tmask[] = [ "mask" => (string)$ft["mask"], "caption" => (string)$ft["caption"], "accept" => (string)$ft["accept"], ]; } } if ($settings->files && $settings->files->grouping) { foreach ($settings->files->grouping as $ft) { $tmaskgrp[] = [ "mask" => (string)$ft["mask"], "caption" => (string)$ft["caption"], "representation" => (string)$ft["representation"], "accept" => (string)$ft["accept"], ]; } } if (count($tmask) == 0) { // no mask defined : accept all kind of files $tmask[] = ["mask" => ".*", "caption" => "", "accept" => ""]; } while ($this->isStarted()) { $path_in = rtrim((string) $settings->hotfolder, '\\/'); $path_in = $filesystem->exists($path_in) ? realpath($path_in) : $path_in; if (!@is_dir($path_in)) { throw new RuntimeException(sprintf('Error : missing hotfolder \'%s\', stopping.', $path_in)); } // copy settings to task, so it's easier to get later $moveArchived = \p4field::isyes($settings->move_archived); $moveError = \p4field::isyes($settings->move_error); clearstatcache(); if (false === $filesystem->exists($path_in . "/.phrasea.xml")) { throw new RuntimeException(sprintf('NO .phrasea.xml AT ROOT \'%s\' !', $path_in)); } $path_archived = $path_error = null; if ($moveArchived) { $path_archived = $path_in . '_archived'; $filesystem->mkdir($path_archived, 0755); } if ($moveError) { $path_error = $path_in . '_error'; $filesystem->mkdir($path_error, 0755); } $dom = new \DOMDocument(); $dom->formatOutput = true; $root = $dom->appendChild($dom->createElement('root')); $nnew = $this->listFilesPhase1($app, $dom, $root, $path_in, $server_coll_id, 0, $TColls); if ($app['debug']) { $this->log('debug', "=========== listFilesPhase1 ========== (returned " . $nnew . ")\n" . $dom->saveXML()); } if (!$this->isStarted()) { return; } // wait for files to be cold $this->pause($cold); if (!$this->isStarted()) { return; } $this->listFilesPhase2($app, $dom, $root, $path_in, 0); if ($app['debug']) { $this->log('debug', "=========== listFilesPhase2 ========== : \n" . $dom->saveXML()); } if (!$this->isStarted()) { return; } $this->makePairs($dom, $root, $path_in, $path_archived, $path_error, false, 0, $tmask, $tmaskgrp); if ($app['debug']) { $this->log('debug', "=========== makePairs ========== : \n" . $dom->saveXML()); } $r = $this->removeBadGroups($app, $dom, $root, $path_in, $path_archived, $path_error, 0, $moveError); if ($app['debug']) { $this->log('debug', "=========== removeBadGroups ========== (returned " . ((Boolean) $r ? 'true' : 'false') . ") : \n" . $dom->saveXML()); } $this->archive($app, $databox, $dom, $root, $path_in, $path_archived, $path_error, 0, $moveError, $moveArchived, $stat0, $stat1); if ($app['debug']) { $this->log('debug', "=========== archive ========== : \n" . $dom->saveXML()); } if (!$this->isStarted()) { return; } $this->bubbleResults($dom, $root, $path_in, 0, \p4field::isyes($settings->copy_spe)); if ($app['debug']) { $this->log('debug', "=========== bubbleResults ========== : \n" . $dom->saveXML()); } $moved = $this->moveFiles($app, $dom, $root, $path_in, $path_archived, $path_error, 0, $moveArchived, $moveError); if ($app['debug']) { $this->log('debug', "=========== moveFiles ========== (returned " . ($moved ? 'true' : 'false') . ") : \n" . $dom->saveXML()); } } }
php
protected function doJob(JobData $data) { $app = $data->getApplication(); $task = $data->getTask(); $settings = simplexml_load_string($task->getSettings()); $baseId = (string) $settings->base_id; $sbasId = \phrasea::sbasFromBas($app, $baseId); if (!$sbasId) { throw new RuntimeException('Invalid collection base_id.'); } $databox = $app->findDataboxById($sbasId); $TColls = []; $collection = null; foreach ($databox->get_collections() as $coll) { $TColls['c' . $coll->get_coll_id()] = $coll->get_coll_id(); if ($baseId == $coll->get_base_id()) { $collection = $coll; } } $server_coll_id = $collection->get_coll_id(); // mask(s) of accepted files $tmask = []; $tmaskgrp = []; $cold = min(max((int) $settings->cold, self::MINCOLD), self::MAXCOLD); $stat0 = $stat1 = "0"; if (false !== $sxBasePrefs = simplexml_load_string($collection->get_prefs())) { if ($sxBasePrefs->status) { $stat0 = (string) $sxBasePrefs->status; } } if ($settings->status) { $stat1 = (string) $settings->status; } if (!$stat0) { $stat0 = '0'; } if (!$stat1) { $stat1 = '0'; } $filesystem = $app['filesystem']; // load masks if ($settings->files && $settings->files->file) { foreach ($settings->files->file as $ft) { $tmask[] = [ "mask" => (string)$ft["mask"], "caption" => (string)$ft["caption"], "accept" => (string)$ft["accept"], ]; } } if ($settings->files && $settings->files->grouping) { foreach ($settings->files->grouping as $ft) { $tmaskgrp[] = [ "mask" => (string)$ft["mask"], "caption" => (string)$ft["caption"], "representation" => (string)$ft["representation"], "accept" => (string)$ft["accept"], ]; } } if (count($tmask) == 0) { // no mask defined : accept all kind of files $tmask[] = ["mask" => ".*", "caption" => "", "accept" => ""]; } while ($this->isStarted()) { $path_in = rtrim((string) $settings->hotfolder, '\\/'); $path_in = $filesystem->exists($path_in) ? realpath($path_in) : $path_in; if (!@is_dir($path_in)) { throw new RuntimeException(sprintf('Error : missing hotfolder \'%s\', stopping.', $path_in)); } // copy settings to task, so it's easier to get later $moveArchived = \p4field::isyes($settings->move_archived); $moveError = \p4field::isyes($settings->move_error); clearstatcache(); if (false === $filesystem->exists($path_in . "/.phrasea.xml")) { throw new RuntimeException(sprintf('NO .phrasea.xml AT ROOT \'%s\' !', $path_in)); } $path_archived = $path_error = null; if ($moveArchived) { $path_archived = $path_in . '_archived'; $filesystem->mkdir($path_archived, 0755); } if ($moveError) { $path_error = $path_in . '_error'; $filesystem->mkdir($path_error, 0755); } $dom = new \DOMDocument(); $dom->formatOutput = true; $root = $dom->appendChild($dom->createElement('root')); $nnew = $this->listFilesPhase1($app, $dom, $root, $path_in, $server_coll_id, 0, $TColls); if ($app['debug']) { $this->log('debug', "=========== listFilesPhase1 ========== (returned " . $nnew . ")\n" . $dom->saveXML()); } if (!$this->isStarted()) { return; } // wait for files to be cold $this->pause($cold); if (!$this->isStarted()) { return; } $this->listFilesPhase2($app, $dom, $root, $path_in, 0); if ($app['debug']) { $this->log('debug', "=========== listFilesPhase2 ========== : \n" . $dom->saveXML()); } if (!$this->isStarted()) { return; } $this->makePairs($dom, $root, $path_in, $path_archived, $path_error, false, 0, $tmask, $tmaskgrp); if ($app['debug']) { $this->log('debug', "=========== makePairs ========== : \n" . $dom->saveXML()); } $r = $this->removeBadGroups($app, $dom, $root, $path_in, $path_archived, $path_error, 0, $moveError); if ($app['debug']) { $this->log('debug', "=========== removeBadGroups ========== (returned " . ((Boolean) $r ? 'true' : 'false') . ") : \n" . $dom->saveXML()); } $this->archive($app, $databox, $dom, $root, $path_in, $path_archived, $path_error, 0, $moveError, $moveArchived, $stat0, $stat1); if ($app['debug']) { $this->log('debug', "=========== archive ========== : \n" . $dom->saveXML()); } if (!$this->isStarted()) { return; } $this->bubbleResults($dom, $root, $path_in, 0, \p4field::isyes($settings->copy_spe)); if ($app['debug']) { $this->log('debug', "=========== bubbleResults ========== : \n" . $dom->saveXML()); } $moved = $this->moveFiles($app, $dom, $root, $path_in, $path_archived, $path_error, 0, $moveArchived, $moveError); if ($app['debug']) { $this->log('debug', "=========== moveFiles ========== (returned " . ($moved ? 'true' : 'false') . ") : \n" . $dom->saveXML()); } } }
[ "protected", "function", "doJob", "(", "JobData", "$", "data", ")", "{", "$", "app", "=", "$", "data", "->", "getApplication", "(", ")", ";", "$", "task", "=", "$", "data", "->", "getTask", "(", ")", ";", "$", "settings", "=", "simplexml_load_string", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php#L69-L230
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php
ArchiveJob.createRecord
public function createRecord(Application $app, \collection $collection, $pathfile, $captionFile, $grp_rid, $force, $stat0, $stat1) { $status = \databox_status::operation_or($stat0, $stat1); $media = $app->getMediaFromUri($pathfile); $databox = $collection->get_databox(); $metadatasStructure = $databox->get_meta_structure(); $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas()); $metaFields = []; if ($captionFile !== null && true === $app['filesystem']->exists($captionFile)) { $metaFields = $this->readXMLForDatabox($app, $metadatasStructure, $captionFile); $captionStatus = $this->parseStatusBit(@simplexml_load_file($captionFile)); if ($captionStatus) { $status = \databox_status::operation_mask($status, $captionStatus); } } $file = new File($app, $media, $collection); $file->addAttribute(new BorderAttribute\Status($app, $status)); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfFilepath(), new MonoValue($media->getFile()->getRealPath())))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfDirname(), new MonoValue(dirname($media->getFile()->getRealPath()))))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfAtime(), new MonoValue($media->getFile()->getATime())))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfMtime(), new MonoValue($media->getFile()->getMTime())))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfCtime(), new MonoValue($media->getFile()->getCTime())))); foreach ($metadatas as $meta) { $file->addAttribute(new BorderAttribute\Metadata($meta)); } foreach ($metaFields as $metaField) { $file->addAttribute($metaField); } if ($grp_rid) { $file->addAttribute(new BorderAttribute\Story(new \record_adapter($app, $databox->get_sbas_id(), $grp_rid))); } $record = null; $postProcess = function ($element, $visa, $code) use (&$record) { $record = $element; }; /** @var borderManager $borderManager */ $borderManager = $app['border-manager']; $borderManager->process($this->getLazaretSession($app), $file, $postProcess, $force); return $record; }
php
public function createRecord(Application $app, \collection $collection, $pathfile, $captionFile, $grp_rid, $force, $stat0, $stat1) { $status = \databox_status::operation_or($stat0, $stat1); $media = $app->getMediaFromUri($pathfile); $databox = $collection->get_databox(); $metadatasStructure = $databox->get_meta_structure(); $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas()); $metaFields = []; if ($captionFile !== null && true === $app['filesystem']->exists($captionFile)) { $metaFields = $this->readXMLForDatabox($app, $metadatasStructure, $captionFile); $captionStatus = $this->parseStatusBit(@simplexml_load_file($captionFile)); if ($captionStatus) { $status = \databox_status::operation_mask($status, $captionStatus); } } $file = new File($app, $media, $collection); $file->addAttribute(new BorderAttribute\Status($app, $status)); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfFilepath(), new MonoValue($media->getFile()->getRealPath())))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfDirname(), new MonoValue(dirname($media->getFile()->getRealPath()))))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfAtime(), new MonoValue($media->getFile()->getATime())))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfMtime(), new MonoValue($media->getFile()->getMTime())))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfCtime(), new MonoValue($media->getFile()->getCTime())))); foreach ($metadatas as $meta) { $file->addAttribute(new BorderAttribute\Metadata($meta)); } foreach ($metaFields as $metaField) { $file->addAttribute($metaField); } if ($grp_rid) { $file->addAttribute(new BorderAttribute\Story(new \record_adapter($app, $databox->get_sbas_id(), $grp_rid))); } $record = null; $postProcess = function ($element, $visa, $code) use (&$record) { $record = $element; }; /** @var borderManager $borderManager */ $borderManager = $app['border-manager']; $borderManager->process($this->getLazaretSession($app), $file, $postProcess, $force); return $record; }
[ "public", "function", "createRecord", "(", "Application", "$", "app", ",", "\\", "collection", "$", "collection", ",", "$", "pathfile", ",", "$", "captionFile", ",", "$", "grp_rid", ",", "$", "force", ",", "$", "stat0", ",", "$", "stat1", ")", "{", "$"...
Creates a record @param \collection $collection The destination collection @param string $pathfile The file to archive @param string|null $captionFile The Phrasea XML caption file or null if no caption file @param integer $grp_rid Add the record to a story @param integer $force Force lazaret or record ; use \Alchemy\Phrasea\Border\Manager::FORCE_* constants @return \record_adapter
[ "Creates", "a", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php#L1032-L1086
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php
ArchiveJob.archiveFile
private function archiveFile(Application $app, \databox $databox, \DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, array &$nodesToDel, $grp_rid, $stat0, $stat1, $moveError, $moveArchived) { $match = $node->getAttribute('match'); if ($match == '*') { return; } $file = $node->getAttribute('name'); $captionFileNode = null; if (!$match) { // the file does not match on any mask $this->log('debug', sprintf("File '%s' does not match any mask", $path . '/' . $file)); $node->setAttribute('error', '1'); return; } if ($match == '?') { // the caption file is missing $this->log('debug', sprintf("Caption of file '%s' is missing", $path . '/' . $file)); $node->setAttribute('error', '1'); return; } if ($match != '.') { // match='.' : the file does not have a separate caption $xpath = new \DOMXPath($dom); $dnl = $xpath->query('./file[@name="' . $match . '"]', $node->parentNode); // in fact, xquery has been done in checkMatch, setting match='?' if caption does not exists... if ($dnl->length == 1) { // ...so we ALWAYS come here $captionFileNode = $dnl->item(0); } else { // ...so we should NEVER come here $node->setAttribute('error', '1'); return; } } $this->archiveFileAndCaption($app, $databox, $dom, $node, $captionFileNode, $path, $path_archived, $path_error, $grp_rid, $nodesToDel, $stat0, $stat1, $moveError, $moveArchived); }
php
private function archiveFile(Application $app, \databox $databox, \DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, array &$nodesToDel, $grp_rid, $stat0, $stat1, $moveError, $moveArchived) { $match = $node->getAttribute('match'); if ($match == '*') { return; } $file = $node->getAttribute('name'); $captionFileNode = null; if (!$match) { // the file does not match on any mask $this->log('debug', sprintf("File '%s' does not match any mask", $path . '/' . $file)); $node->setAttribute('error', '1'); return; } if ($match == '?') { // the caption file is missing $this->log('debug', sprintf("Caption of file '%s' is missing", $path . '/' . $file)); $node->setAttribute('error', '1'); return; } if ($match != '.') { // match='.' : the file does not have a separate caption $xpath = new \DOMXPath($dom); $dnl = $xpath->query('./file[@name="' . $match . '"]', $node->parentNode); // in fact, xquery has been done in checkMatch, setting match='?' if caption does not exists... if ($dnl->length == 1) { // ...so we ALWAYS come here $captionFileNode = $dnl->item(0); } else { // ...so we should NEVER come here $node->setAttribute('error', '1'); return; } } $this->archiveFileAndCaption($app, $databox, $dom, $node, $captionFileNode, $path, $path_archived, $path_error, $grp_rid, $nodesToDel, $stat0, $stat1, $moveError, $moveArchived); }
[ "private", "function", "archiveFile", "(", "Application", "$", "app", ",", "\\", "databox", "$", "databox", ",", "\\", "DOMDocument", "$", "dom", ",", "\\", "DOMElement", "$", "node", ",", "$", "path", ",", "$", "path_archived", ",", "$", "path_error", "...
Archive File @param \DOMDocument $dom @param \DOMElement $node @param string $path @param string $path_archived @param string $path_error @param array $nodesToDel out, filled with files to delete @param integer $grp_rid
[ "Archive", "File" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php#L1134-L1175
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php
ArchiveJob.setAllChildren
private function setAllChildren(\DOMDocument $dom, \DOMElement $node, array $attributes, $depth = 0) { static $iloop = 0; if ($depth == 0) { $iloop = 0; } foreach ($attributes as $a => $v) { $node->setAttribute($a, $v); } if (($iloop++ % 100) == 0) { usleep(1000); } for ($n = $node->firstChild; $n; $n = $n->nextSibling) { $this->setAllChildren($dom, $n, $attributes, $depth + 1); } }
php
private function setAllChildren(\DOMDocument $dom, \DOMElement $node, array $attributes, $depth = 0) { static $iloop = 0; if ($depth == 0) { $iloop = 0; } foreach ($attributes as $a => $v) { $node->setAttribute($a, $v); } if (($iloop++ % 100) == 0) { usleep(1000); } for ($n = $node->firstChild; $n; $n = $n->nextSibling) { $this->setAllChildren($dom, $n, $attributes, $depth + 1); } }
[ "private", "function", "setAllChildren", "(", "\\", "DOMDocument", "$", "dom", ",", "\\", "DOMElement", "$", "node", ",", "array", "$", "attributes", ",", "$", "depth", "=", "0", ")", "{", "static", "$", "iloop", "=", "0", ";", "if", "(", "$", "depth...
xml facility : set attributes to a node and all children @staticvar integer $iloop @param \DOMDocument $dom @param \DOMElement $node @param array $attributes An associative array of attributes @param integer $depth
[ "xml", "facility", ":", "set", "attributes", "to", "a", "node", "and", "all", "children" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php#L1313-L1331
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php
ArchiveJob.getGrpSettings
private function getGrpSettings($file, $tmaskgrp) { $matched = false; foreach ($tmaskgrp as $maskgrp) { $preg_maskgrp = "/" . $maskgrp["mask"] . "/"; if (preg_match($preg_maskgrp, $file)) { $matched = $maskgrp; } if ($matched) { break; } } return $matched; }
php
private function getGrpSettings($file, $tmaskgrp) { $matched = false; foreach ($tmaskgrp as $maskgrp) { $preg_maskgrp = "/" . $maskgrp["mask"] . "/"; if (preg_match($preg_maskgrp, $file)) { $matched = $maskgrp; } if ($matched) { break; } } return $matched; }
[ "private", "function", "getGrpSettings", "(", "$", "file", ",", "$", "tmaskgrp", ")", "{", "$", "matched", "=", "false", ";", "foreach", "(", "$", "tmaskgrp", "as", "$", "maskgrp", ")", "{", "$", "preg_maskgrp", "=", "\"/\"", ".", "$", "maskgrp", "[", ...
Return the story settings @param string $file @return array
[ "Return", "the", "story", "settings" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php#L1339-L1354
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php
ArchiveJob.getLazaretSession
protected function getLazaretSession(Application $app) { $lazaretSession = new LazaretSession(); $app['orm.em']->persist($lazaretSession); $app['orm.em']->flush(); return $lazaretSession; }
php
protected function getLazaretSession(Application $app) { $lazaretSession = new LazaretSession(); $app['orm.em']->persist($lazaretSession); $app['orm.em']->flush(); return $lazaretSession; }
[ "protected", "function", "getLazaretSession", "(", "Application", "$", "app", ")", "{", "$", "lazaretSession", "=", "new", "LazaretSession", "(", ")", ";", "$", "app", "[", "'orm.em'", "]", "->", "persist", "(", "$", "lazaretSession", ")", ";", "$", "app",...
Return a LazaretSession @return LazaretSession
[ "Return", "a", "LazaretSession" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php#L1361-L1369
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php
ArchiveJob.getIndexByFieldName
protected function getIndexByFieldName(\databox_descriptionStructure $metadatasStructure, ExiftoolMetadataBag $bag) { $ret = new MetadataBag(); foreach ($metadatasStructure as $databox_field) { if ($bag->containsKey($databox_field->get_tag()->getTagname())) { $ret->set($databox_field->get_name(), $bag->get($databox_field->get_tag()->getTagname())); } } return $ret; }
php
protected function getIndexByFieldName(\databox_descriptionStructure $metadatasStructure, ExiftoolMetadataBag $bag) { $ret = new MetadataBag(); foreach ($metadatasStructure as $databox_field) { if ($bag->containsKey($databox_field->get_tag()->getTagname())) { $ret->set($databox_field->get_name(), $bag->get($databox_field->get_tag()->getTagname())); } } return $ret; }
[ "protected", "function", "getIndexByFieldName", "(", "\\", "databox_descriptionStructure", "$", "metadatasStructure", ",", "ExiftoolMetadataBag", "$", "bag", ")", "{", "$", "ret", "=", "new", "MetadataBag", "(", ")", ";", "foreach", "(", "$", "metadatasStructure", ...
Map a Bag of metadatas indexed by **Tagnames** to a bag of metadatas indexed by **FieldNames** @param \databox_descriptionStructure $metadatasStructure The databox structure related @param ExiftoolMetadataBag $bag The metadata bag @return MetadataBag
[ "Map", "a", "Bag", "of", "metadatas", "indexed", "by", "**", "Tagnames", "**", "to", "a", "bag", "of", "metadatas", "indexed", "by", "**", "FieldNames", "**" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php#L1379-L1390
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php
ArchiveJob.parseStatusBit
protected function parseStatusBit($sxcaption) { if (!$sxcaption instanceof \SimpleXMLElement) { return null; } if ('' !== $inStatus = (string) $sxcaption->status) { return $inStatus; } return null; }
php
protected function parseStatusBit($sxcaption) { if (!$sxcaption instanceof \SimpleXMLElement) { return null; } if ('' !== $inStatus = (string) $sxcaption->status) { return $inStatus; } return null; }
[ "protected", "function", "parseStatusBit", "(", "$", "sxcaption", ")", "{", "if", "(", "!", "$", "sxcaption", "instanceof", "\\", "SimpleXMLElement", ")", "{", "return", "null", ";", "}", "if", "(", "''", "!==", "$", "inStatus", "=", "(", "string", ")", ...
Parse a Phrasea XML to find status tag @param \SimpleXMLElement $sxcaption The SimpleXML related to the XML @return string
[ "Parse", "a", "Phrasea", "XML", "to", "find", "status", "tag" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php#L1436-L1447
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/Manager.php
Manager.process
public function process(LazaretSession $session, File $file, $callable = null, $forceBehavior = null, $nosubdef = false) { $visa = $this->getVisa($file); // Generate UUID $file->getUUID(true, false); if (($visa->isValid() || $forceBehavior === self::FORCE_RECORD) && $forceBehavior !== self::FORCE_LAZARET) { $this->addMediaAttributes($file); $element = $this->createRecord($file, $nosubdef); $code = self::RECORD_CREATED; } else { $element = $this->createLazaret($file, $visa, $session, $forceBehavior === self::FORCE_LAZARET); $code = self::LAZARET_CREATED; } // Write UUID $file->getUUID(false, true); if (is_callable($callable)) { $callable($element, $visa, $code); } return $code; }
php
public function process(LazaretSession $session, File $file, $callable = null, $forceBehavior = null, $nosubdef = false) { $visa = $this->getVisa($file); // Generate UUID $file->getUUID(true, false); if (($visa->isValid() || $forceBehavior === self::FORCE_RECORD) && $forceBehavior !== self::FORCE_LAZARET) { $this->addMediaAttributes($file); $element = $this->createRecord($file, $nosubdef); $code = self::RECORD_CREATED; } else { $element = $this->createLazaret($file, $visa, $session, $forceBehavior === self::FORCE_LAZARET); $code = self::LAZARET_CREATED; } // Write UUID $file->getUUID(false, true); if (is_callable($callable)) { $callable($element, $visa, $code); } return $code; }
[ "public", "function", "process", "(", "LazaretSession", "$", "session", ",", "File", "$", "file", ",", "$", "callable", "=", "null", ",", "$", "forceBehavior", "=", "null", ",", "$", "nosubdef", "=", "false", ")", "{", "$", "visa", "=", "$", "this", ...
Add a file to Phraseanet after having checked it @param LazaretSession $session The current Lazaret Session @param File $file A File package object @param callable $callable A callback to execute after process (arguments are $element (LazaretFile or \record_adapter), $visa (Visa) and $code (self::RECORD_CREATED or self::LAZARET_CREATED)) @param bool $forceBehavior Force a behavior, one of the self::FORCE_* constant @return int One of the self::RECORD_CREATED or self::LAZARET_CREATED constants
[ "Add", "a", "file", "to", "Phraseanet", "after", "having", "checked", "it" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Manager.php#L104-L133
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/Manager.php
Manager.getVisa
public function getVisa(File $file) { $visa = new Visa(); if (!$this->isEnabled()) { return $visa; } foreach ($this->checkers as $checker) { if ($checker->isApplicable($file)) { $visa->addResponse($checker->check($this->app['orm.em'], $file)); } } return $visa; }
php
public function getVisa(File $file) { $visa = new Visa(); if (!$this->isEnabled()) { return $visa; } foreach ($this->checkers as $checker) { if ($checker->isApplicable($file)) { $visa->addResponse($checker->check($this->app['orm.em'], $file)); } } return $visa; }
[ "public", "function", "getVisa", "(", "File", "$", "file", ")", "{", "$", "visa", "=", "new", "Visa", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", "$", "visa", ";", "}", "foreach", "(", "$", "this...
Check a File package object against the Checkers, and returns a Visa @param File $file A File package object @return Visa The Visa
[ "Check", "a", "File", "package", "object", "against", "the", "Checkers", "and", "returns", "a", "Visa" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Manager.php#L141-L156
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/Manager.php
Manager.registerChecker
public function registerChecker(CheckerInterface $checker) { if (!$this->hasChecker($checker)) { $this->checkers[] = $checker; } return $this; }
php
public function registerChecker(CheckerInterface $checker) { if (!$this->hasChecker($checker)) { $this->checkers[] = $checker; } return $this; }
[ "public", "function", "registerChecker", "(", "CheckerInterface", "$", "checker", ")", "{", "if", "(", "!", "$", "this", "->", "hasChecker", "(", "$", "checker", ")", ")", "{", "$", "this", "->", "checkers", "[", "]", "=", "$", "checker", ";", "}", "...
Registers a checker @param CheckerInterface $checker The checker to register @return Manager
[ "Registers", "a", "checker" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Manager.php#L164-L171
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/Manager.php
Manager.unregisterChecker
public function unregisterChecker(CheckerInterface $checker) { if (false === $this->hasChecker($checker)) { throw new \LogicException('Trying to unregister unregistered checker'); } foreach ($this->checkers as $key => $registeredChecker) { if ($checker === $registeredChecker) { unset($this->checkers[$key]); } } return $this; }
php
public function unregisterChecker(CheckerInterface $checker) { if (false === $this->hasChecker($checker)) { throw new \LogicException('Trying to unregister unregistered checker'); } foreach ($this->checkers as $key => $registeredChecker) { if ($checker === $registeredChecker) { unset($this->checkers[$key]); } } return $this; }
[ "public", "function", "unregisterChecker", "(", "CheckerInterface", "$", "checker", ")", "{", "if", "(", "false", "===", "$", "this", "->", "hasChecker", "(", "$", "checker", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Trying to unregister un...
Unregister a checker @param CheckerInterface $checker The checker to unregister @return Manager
[ "Unregister", "a", "checker" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Manager.php#L209-L222
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/Manager.php
Manager.getCheckerFromFQCN
public function getCheckerFromFQCN($checkerName) { $checkerName = trim($checkerName, '\\'); if (!class_exists($checkerName)) { throw new \RuntimeException('Checker FQCN does not exists'); } foreach ($this->checkers as $checker) { if ($checker instanceof $checkerName) { return $checker; } } throw new RuntimeException('Checker could not be found'); }
php
public function getCheckerFromFQCN($checkerName) { $checkerName = trim($checkerName, '\\'); if (!class_exists($checkerName)) { throw new \RuntimeException('Checker FQCN does not exists'); } foreach ($this->checkers as $checker) { if ($checker instanceof $checkerName) { return $checker; } } throw new RuntimeException('Checker could not be found'); }
[ "public", "function", "getCheckerFromFQCN", "(", "$", "checkerName", ")", "{", "$", "checkerName", "=", "trim", "(", "$", "checkerName", ",", "'\\\\'", ")", ";", "if", "(", "!", "class_exists", "(", "$", "checkerName", ")", ")", "{", "throw", "new", "\\"...
Get checker instance from its class name. @param string $checkerName @return CheckerInterface
[ "Get", "checker", "instance", "from", "its", "class", "name", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Manager.php#L230-L244
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/Manager.php
Manager.createRecord
protected function createRecord(File $file, $nosubdef=false) { $element = \record_adapter::createFromFile($file, $this->app); $date = new \DateTime(); $file->addAttribute( new MetadataAttr( new Metadata( new TfArchivedate(), new MonoValue($date->format('Y/m/d H:i:s')) ) ) ); $file->addAttribute( new MetadataAttr( new Metadata( new TfRecordid(), new MonoValue($element->getRecordId()) ) ) ); $file->addAttribute( new MetadataAttr( new Metadata( new TfBasename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_BASENAME)) ) ) ); $file->addAttribute( new MetadataAttr( new Metadata( new TfFilename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_FILENAME)) ) ) ); $newMetadata = $file->getMedia()->getMetadatas()->toArray(); foreach ($file->getAttributes() as $attribute) { switch ($attribute->getName()) { case AttributeInterface::NAME_METAFIELD: /** @var MetafieldAttr $attribute */ $values = $attribute->getValue(); $value = $attribute->getField()->is_multi() ? new Multi($values) : new MonoValue(array_pop($values)); $newMetadata[] = new Metadata($attribute->getField()->get_tag(), $value); break; case AttributeInterface::NAME_METADATA: /** @var MetadataAttr $attribute */ $newMetadata[] = $attribute->getValue(); break; case AttributeInterface::NAME_STATUS: /** @var StatusAttr $attribute */ $element->setStatus(decbin(bindec($element->getStatus()) | bindec($attribute->getValue()))); break; case AttributeInterface::NAME_STORY: /** @var StoryAttr $attribute */ $story = $attribute->getValue(); if ( ! $story->hasChild($element)) { $story->appendChild($element); } break; } } $this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element); if(!$nosubdef) { $element->rebuild_subdefs(); } return $element; }
php
protected function createRecord(File $file, $nosubdef=false) { $element = \record_adapter::createFromFile($file, $this->app); $date = new \DateTime(); $file->addAttribute( new MetadataAttr( new Metadata( new TfArchivedate(), new MonoValue($date->format('Y/m/d H:i:s')) ) ) ); $file->addAttribute( new MetadataAttr( new Metadata( new TfRecordid(), new MonoValue($element->getRecordId()) ) ) ); $file->addAttribute( new MetadataAttr( new Metadata( new TfBasename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_BASENAME)) ) ) ); $file->addAttribute( new MetadataAttr( new Metadata( new TfFilename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_FILENAME)) ) ) ); $newMetadata = $file->getMedia()->getMetadatas()->toArray(); foreach ($file->getAttributes() as $attribute) { switch ($attribute->getName()) { case AttributeInterface::NAME_METAFIELD: /** @var MetafieldAttr $attribute */ $values = $attribute->getValue(); $value = $attribute->getField()->is_multi() ? new Multi($values) : new MonoValue(array_pop($values)); $newMetadata[] = new Metadata($attribute->getField()->get_tag(), $value); break; case AttributeInterface::NAME_METADATA: /** @var MetadataAttr $attribute */ $newMetadata[] = $attribute->getValue(); break; case AttributeInterface::NAME_STATUS: /** @var StatusAttr $attribute */ $element->setStatus(decbin(bindec($element->getStatus()) | bindec($attribute->getValue()))); break; case AttributeInterface::NAME_STORY: /** @var StoryAttr $attribute */ $story = $attribute->getValue(); if ( ! $story->hasChild($element)) { $story->appendChild($element); } break; } } $this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element); if(!$nosubdef) { $element->rebuild_subdefs(); } return $element; }
[ "protected", "function", "createRecord", "(", "File", "$", "file", ",", "$", "nosubdef", "=", "false", ")", "{", "$", "element", "=", "\\", "record_adapter", "::", "createFromFile", "(", "$", "file", ",", "$", "this", "->", "app", ")", ";", "$", "date"...
Adds a record to Phraseanet @param File $file The package file @return \record_adapter
[ "Adds", "a", "record", "to", "Phraseanet" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Manager.php#L266-L340
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/Manager.php
Manager.createLazaret
protected function createLazaret(File $file, Visa $visa, LazaretSession $session, $forced) { $date = new \DateTime(); $file->addAttribute( new MetadataAttr( new Metadata( new TfQuarantine(), new MonoValue($date->format('Y/m/d H:i:s')) ) ) ); $lazaretFilesystemService = $this->app['phraseanet.lazaret_filesystem']; $persistedLazaret = $lazaretFilesystemService->writeLazaret($file); $lazaretFile = new LazaretFile(); $lazaretFile->setBaseId($file->getCollection()->get_base_id()); $lazaretFile->setSha256($file->getSha256()); $lazaretFile->setUuid($file->getUUID()); $lazaretFile->setOriginalName($file->getOriginalName()); $lazaretFile->setForced($forced); $lazaretFile->setFilename($persistedLazaret->getFilename()); $lazaretFile->setThumbFileName($persistedLazaret->getThumbnailFilename()); $lazaretFile->setSession($session); $this->app['orm.em']->persist($lazaretFile); foreach ($file->getAttributes() as $fileAttribute) { $attribute = new LazaretAttribute(); $attribute->setName($fileAttribute->getName()); $attribute->setValue($fileAttribute->asString()); $attribute->setLazaretFile($lazaretFile); $lazaretFile->addAttribute($attribute); $this->app['orm.em']->persist($attribute); } foreach ($visa->getResponses() as $response) { if ( ! $response->isOk()) { $check = new LazaretCheck(); $check->setCheckClassname(get_class($response->getChecker())); $check->setLazaretFile($lazaretFile); $lazaretFile->addCheck($check); $this->app['orm.em']->persist($check); } } $this->app['orm.em']->flush(); return $lazaretFile; }
php
protected function createLazaret(File $file, Visa $visa, LazaretSession $session, $forced) { $date = new \DateTime(); $file->addAttribute( new MetadataAttr( new Metadata( new TfQuarantine(), new MonoValue($date->format('Y/m/d H:i:s')) ) ) ); $lazaretFilesystemService = $this->app['phraseanet.lazaret_filesystem']; $persistedLazaret = $lazaretFilesystemService->writeLazaret($file); $lazaretFile = new LazaretFile(); $lazaretFile->setBaseId($file->getCollection()->get_base_id()); $lazaretFile->setSha256($file->getSha256()); $lazaretFile->setUuid($file->getUUID()); $lazaretFile->setOriginalName($file->getOriginalName()); $lazaretFile->setForced($forced); $lazaretFile->setFilename($persistedLazaret->getFilename()); $lazaretFile->setThumbFileName($persistedLazaret->getThumbnailFilename()); $lazaretFile->setSession($session); $this->app['orm.em']->persist($lazaretFile); foreach ($file->getAttributes() as $fileAttribute) { $attribute = new LazaretAttribute(); $attribute->setName($fileAttribute->getName()); $attribute->setValue($fileAttribute->asString()); $attribute->setLazaretFile($lazaretFile); $lazaretFile->addAttribute($attribute); $this->app['orm.em']->persist($attribute); } foreach ($visa->getResponses() as $response) { if ( ! $response->isOk()) { $check = new LazaretCheck(); $check->setCheckClassname(get_class($response->getChecker())); $check->setLazaretFile($lazaretFile); $lazaretFile->addCheck($check); $this->app['orm.em']->persist($check); } } $this->app['orm.em']->flush(); return $lazaretFile; }
[ "protected", "function", "createLazaret", "(", "File", "$", "file", ",", "Visa", "$", "visa", ",", "LazaretSession", "$", "session", ",", "$", "forced", ")", "{", "$", "date", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "file", "->", "addAttribut...
Send a package file to lazaret @param File $file The package file @param Visa $visa The visa related to the package file @param LazaretSession $session The current LazaretSession @param Boolean $forced True if the file has been forced to quarantine @return LazaretFile
[ "Send", "a", "package", "file", "to", "lazaret" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Manager.php#L352-L407
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/Manager.php
Manager.addMediaAttributes
protected function addMediaAttributes(File $file) { $metadataCollection = $this->app['phraseanet.metadata-reader']->read($file->getMedia()); array_walk($metadataCollection, function (Metadata $metadata) use ($file) { $file->addAttribute(new MetadataAttr($metadata)); }); return $this; }
php
protected function addMediaAttributes(File $file) { $metadataCollection = $this->app['phraseanet.metadata-reader']->read($file->getMedia()); array_walk($metadataCollection, function (Metadata $metadata) use ($file) { $file->addAttribute(new MetadataAttr($metadata)); }); return $this; }
[ "protected", "function", "addMediaAttributes", "(", "File", "$", "file", ")", "{", "$", "metadataCollection", "=", "$", "this", "->", "app", "[", "'phraseanet.metadata-reader'", "]", "->", "read", "(", "$", "file", "->", "getMedia", "(", ")", ")", ";", "ar...
Add technical Metadata attribute to a package file by reference to add it to Phraseanet @param File $file The file @return Manager
[ "Add", "technical", "Metadata", "attribute", "to", "a", "package", "file", "by", "reference", "to", "add", "it", "to", "Phraseanet" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Manager.php#L417-L426
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/SessionHandlerFactory.php
SessionHandlerFactory.create
public function create(PropertyAccess $conf) { $type = $conf->get(['main', 'session', 'type'], 'file'); $options = $conf->get(['main', 'session', 'options'], []); $serverOpts = [ 'expiretime' => $conf->get(['main', 'session', 'ttl'], 86400), 'prefix' => $conf->get(['main', 'key']), ]; switch (strtolower($type)) { case 'memcache': return new WriteCheckSessionHandler( new MemcacheSessionHandler( $this->connectionFactory->getMemcacheConnection($options, $serverOpts) ) ); case 'memcached': return new WriteCheckSessionHandler( new MemcachedSessionHandler( $this->connectionFactory->getMemcachedConnection($options, $serverOpts) ) ); case 'file': return new NativeFileSessionHandler(isset($options['save-path']) ? $options['save-path'] : null); case 'redis': return new WriteCheckSessionHandler( new RedisSessionHandler( $this->connectionFactory->getRedisConnection($options, $serverOpts) ) ); case 'native': return new NativeSessionHandler(); } throw new RuntimeException(sprintf('Unable to create the specified session handler "%s"', $type)); }
php
public function create(PropertyAccess $conf) { $type = $conf->get(['main', 'session', 'type'], 'file'); $options = $conf->get(['main', 'session', 'options'], []); $serverOpts = [ 'expiretime' => $conf->get(['main', 'session', 'ttl'], 86400), 'prefix' => $conf->get(['main', 'key']), ]; switch (strtolower($type)) { case 'memcache': return new WriteCheckSessionHandler( new MemcacheSessionHandler( $this->connectionFactory->getMemcacheConnection($options, $serverOpts) ) ); case 'memcached': return new WriteCheckSessionHandler( new MemcachedSessionHandler( $this->connectionFactory->getMemcachedConnection($options, $serverOpts) ) ); case 'file': return new NativeFileSessionHandler(isset($options['save-path']) ? $options['save-path'] : null); case 'redis': return new WriteCheckSessionHandler( new RedisSessionHandler( $this->connectionFactory->getRedisConnection($options, $serverOpts) ) ); case 'native': return new NativeSessionHandler(); } throw new RuntimeException(sprintf('Unable to create the specified session handler "%s"', $type)); }
[ "public", "function", "create", "(", "PropertyAccess", "$", "conf", ")", "{", "$", "type", "=", "$", "conf", "->", "get", "(", "[", "'main'", ",", "'session'", ",", "'type'", "]", ",", "'file'", ")", ";", "$", "options", "=", "$", "conf", "->", "ge...
Creates a SessionHandlerInterface given a conf. @param PropertyAccess $conf @return \SessionHandlerInterface @throws \Alchemy\Phrasea\Exception\RuntimeException
[ "Creates", "a", "SessionHandlerInterface", "given", "a", "conf", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/SessionHandlerFactory.php#L41-L76
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php
HostConfiguration.setHost
public function setHost($host) { $this->host = trim(strtolower($host)); if ('' === $this->host) { $this->merge(); return; } if (!isset($this->cache['hosts-configuration'])) { $this->merge(); return; } foreach ($this->cache['hosts-configuration'] as $hostConf) { if (!isset($hostConf['servername'])) { continue; } if ($this->match($this->host, $hostConf['servername'])) { $this->merge($hostConf); break; } if (!isset($hostConf['hosts'])) { continue; } foreach ((array) $hostConf['hosts'] as $hostname) { if ($this->match($this->host, $hostname)) { $this->merge($hostConf); break 2; } } } }
php
public function setHost($host) { $this->host = trim(strtolower($host)); if ('' === $this->host) { $this->merge(); return; } if (!isset($this->cache['hosts-configuration'])) { $this->merge(); return; } foreach ($this->cache['hosts-configuration'] as $hostConf) { if (!isset($hostConf['servername'])) { continue; } if ($this->match($this->host, $hostConf['servername'])) { $this->merge($hostConf); break; } if (!isset($hostConf['hosts'])) { continue; } foreach ((array) $hostConf['hosts'] as $hostname) { if ($this->match($this->host, $hostname)) { $this->merge($hostConf); break 2; } } } }
[ "public", "function", "setHost", "(", "$", "host", ")", "{", "$", "this", "->", "host", "=", "trim", "(", "strtolower", "(", "$", "host", ")", ")", ";", "if", "(", "''", "===", "$", "this", "->", "host", ")", "{", "$", "this", "->", "merge", "(...
Sets the host name to switch on. @param $host
[ "Sets", "the", "host", "name", "to", "switch", "on", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php#L33-L67
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php
HostConfiguration.offsetSet
public function offsetSet($offset, $value) { $this->configuration[$offset] = $value; $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); }
php
public function offsetSet($offset, $value) { $this->configuration[$offset] = $value; $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "$", "this", "->", "configuration", "[", "$", "offset", "]", "=", "$", "value", ";", "$", "this", "->", "cache", "=", "$", "this", "->", "configuration", "->", "getCo...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php#L80-L85
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php
HostConfiguration.offsetUnset
public function offsetUnset($offset) { $this->configuration->offsetUnset($offset); $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); }
php
public function offsetUnset($offset) { $this->configuration->offsetUnset($offset); $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); }
[ "public", "function", "offsetUnset", "(", "$", "offset", ")", "{", "$", "this", "->", "configuration", "->", "offsetUnset", "(", "$", "offset", ")", ";", "$", "this", "->", "cache", "=", "$", "this", "->", "configuration", "->", "getConfig", "(", ")", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php#L98-L103
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php
HostConfiguration.initialize
public function initialize() { $this->configuration->initialize(); $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); return $this; }
php
public function initialize() { $this->configuration->initialize(); $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); return $this; }
[ "public", "function", "initialize", "(", ")", "{", "$", "this", "->", "configuration", "->", "initialize", "(", ")", ";", "$", "this", "->", "cache", "=", "$", "this", "->", "configuration", "->", "getConfig", "(", ")", ";", "$", "this", "->", "setHost...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php#L108-L115
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php
HostConfiguration.delete
public function delete() { $this->configuration->delete(); $this->cache = []; $this->setHost($this->host); return $this; }
php
public function delete() { $this->configuration->delete(); $this->cache = []; $this->setHost($this->host); return $this; }
[ "public", "function", "delete", "(", ")", "{", "$", "this", "->", "configuration", "->", "delete", "(", ")", ";", "$", "this", "->", "cache", "=", "[", "]", ";", "$", "this", "->", "setHost", "(", "$", "this", "->", "host", ")", ";", "return", "$...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php#L120-L127
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php
HostConfiguration.setDefault
public function setDefault($name) { $this->configuration->setDefault($name); $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); return $this; }
php
public function setDefault($name) { $this->configuration->setDefault($name); $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); return $this; }
[ "public", "function", "setDefault", "(", "$", "name", ")", "{", "$", "this", "->", "configuration", "->", "setDefault", "(", "$", "name", ")", ";", "$", "this", "->", "cache", "=", "$", "this", "->", "configuration", "->", "getConfig", "(", ")", ";", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php#L140-L147
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php
HostConfiguration.setConfig
public function setConfig(array $config) { $this->configuration->setConfig($config); $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); return $this; }
php
public function setConfig(array $config) { $this->configuration->setConfig($config); $this->cache = $this->configuration->getConfig(); $this->setHost($this->host); return $this; }
[ "public", "function", "setConfig", "(", "array", "$", "config", ")", "{", "$", "this", "->", "configuration", "->", "setConfig", "(", "$", "config", ")", ";", "$", "this", "->", "cache", "=", "$", "this", "->", "configuration", "->", "getConfig", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php#L164-L171