本文整理汇总了PHP中collection::mount_collection方法的典型用法代码示例。如果您正苦于以下问题:PHP collection::mount_collection方法的具体用法?PHP collection::mount_collection怎么用?PHP collection::mount_collection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collection
的用法示例。
在下文中一共展示了collection::mount_collection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mountCollection
/**
* Mount a collection on a databox
*
* @param Application $app The silex application
* @param Request $request The current HTTP request
* @param integer $databox_id The requested databox
* @param integer $collection_id The requested collection id
* @return RedirectResponse
*/
public function mountCollection(Application $app, Request $request, $databox_id, $collection_id)
{
$app['phraseanet.appbox']->get_connection()->beginTransaction();
try {
$baseId = \collection::mount_collection($app, $app['phraseanet.appbox']->get_databox($databox_id), $collection_id, $app['authentication']->getUser());
$othCollSel = (int) $request->request->get("othcollsel") ?: null;
if (null !== $othCollSel) {
$query = $app['phraseanet.user-query'];
$n = 0;
while ($n < $query->on_base_ids([$othCollSel])->get_total()) {
$results = $query->limit($n, 50)->execute()->get_results();
foreach ($results as $user) {
$app['acl']->get($user)->duplicate_right_from_bas($othCollSel, $baseId);
}
$n += 50;
}
}
$app['phraseanet.appbox']->get_connection()->commit();
return $app->redirectPath('admin_database', ['databox_id' => $databox_id, 'mount' => 'ok']);
} catch (\Exception $e) {
$app['phraseanet.appbox']->get_connection()->rollBack();
return $app->redirectPath('admin_database', ['databox_id' => $databox_id, 'mount' => 'ko']);
}
}
示例2: mountCollection
/**
* Mount a collection on a databox
*
* @param Request $request The current HTTP request
* @param integer $databox_id The requested databox
* @param integer $collection_id The requested collection id
* @return RedirectResponse
*/
public function mountCollection(Request $request, $databox_id, $collection_id)
{
$connection = $this->getApplicationBox()->get_connection();
$connection->beginTransaction();
try {
/** @var Authenticator $authenticator */
$authenticator = $this->app->getAuthenticator();
$baseId = \collection::mount_collection($this->app, $this->findDataboxById($databox_id), $collection_id, $authenticator->getUser());
$othCollSel = (int) $request->request->get("othcollsel") ?: null;
if (null !== $othCollSel) {
$query = $this->createUserQuery();
$n = 0;
/** @var ACLProvider $aclProvider */
$aclProvider = $this->app['acl'];
while ($n < $query->on_base_ids([$othCollSel])->get_total()) {
$results = $query->limit($n, 50)->execute()->get_results();
foreach ($results as $user) {
$aclProvider->get($user)->duplicate_right_from_bas($othCollSel, $baseId);
}
$n += 50;
}
}
$connection->commit();
return $this->app->redirectPath('admin_database', ['databox_id' => $databox_id, 'mount' => 'ok']);
} catch (\Exception $e) {
$connection->rollBack();
return $this->app->redirectPath('admin_database', ['databox_id' => $databox_id, 'mount' => 'ko']);
}
}