本文整理汇总了PHP中ServiceUtil::getService方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceUtil::getService方法的具体用法?PHP ServiceUtil::getService怎么用?PHP ServiceUtil::getService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceUtil
的用法示例。
在下文中一共展示了ServiceUtil::getService方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAlbumJsTree
/**
* Tree array for jstree
*
* @return tree array
*/
public function getAlbumJsTree()
{
$em = \ServiceUtil::getService('doctrine.entitymanager');
$repository = $em->getRepository('Kaikmedia\\GalleryModule\\Entity\\AlbumEntity');
$albums = $repository->findAll();
foreach ($albums as $album) {
$arrayTree[] = $album->getAsJsTreeArray();
}
return $arrayTree;
}
示例2: onCreateUser
/**
* On an module remove hook call this listener
*
* Listens for the 'user.account.create' event.
*
* @param Zikula_Event $event Event.
*/
public static function onCreateUser(Zikula_Event $event)
{
if (!ModUtil::getVar('Dashboard', 'widgetsnewuser', false)) {
return;
}
$user = $event->getSubject();
$helper = new Dashboard_Helper_WidgetHelper(ServiceUtil::getService('doctrine.entitymanager'));
$widgets = $helper->getRegisteredWidgets($user['uid']);
foreach ($widgets as $widget) {
Dashboard_Util::addUserWidget($user['uid'], $widget);
}
}
示例3: build
/**
* Query builder helper
*
* @return \Kaikmedia\GalleryModule\Entity\GalleryQueryBuilder
*/
public function build()
{
$em = \ServiceUtil::getService('doctrine.entitymanager');
$qb = new MediaQueryBuilder($em);
return $qb;
}
示例4: search
/**
* Executes the actual search process.
*
* @param array $args List of arguments.
*
* @return boolean
*
* @throws RuntimeException Thrown if search results can not be saved
*/
public function search(array $args = array())
{
if (!SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) {
return '';
}
// ensure that database information of Search module is loaded
ModUtil::dbInfoLoad('Search');
// save session id as it is used when inserting search results below
$sessionId = session_id();
// retrieve list of activated object types
$searchTypes = isset($args['objectTypes']) ? (array) $args['objectTypes'] : (array) FormUtil::getPassedValue('reviewsSearchTypes', array(), 'GETPOST');
$controllerHelper = new Reviews_Util_Controller($this->serviceManager);
$utilArgs = array('api' => 'search', 'action' => 'search');
$allowedTypes = $controllerHelper->getObjectTypes('api', $utilArgs);
$entityManager = ServiceUtil::getService('doctrine.entitymanager');
$currentPage = 1;
$resultsPerPage = 50;
foreach ($searchTypes as $objectType) {
if (!in_array($objectType, $allowedTypes)) {
continue;
}
$whereArray = array();
$languageField = null;
switch ($objectType) {
case 'review':
$whereArray[] = 'tbl.workflowState';
$whereArray[] = 'tbl.title';
$whereArray[] = 'tbl.text';
$whereArray[] = 'tbl.zlanguage';
$whereArray[] = 'tbl.reviewer';
$whereArray[] = 'tbl.email';
$whereArray[] = 'tbl.score';
$whereArray[] = 'tbl.url';
$whereArray[] = 'tbl.url_title';
$whereArray[] = 'tbl.cover';
$whereArray[] = 'tbl.coverUpload';
$languageField = 'zlanguage';
break;
}
$where = Search_Api_User::construct_where($args, $whereArray);
$entityClass = $this->name . '_Entity_' . ucwords($objectType);
$repository = $entityManager->getRepository($entityClass);
// get objects from database
list($entities, $objectCount) = $repository->selectWherePaginated($where, '', $currentPage, $resultsPerPage, false);
if ($objectCount == 0) {
continue;
}
$idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType));
$descriptionField = $repository->getDescriptionFieldName();
foreach ($entities as $entity) {
$urlArgs = array('ot' => $objectType);
// create identifier for permission check
$instanceId = '';
foreach ($idFields as $idField) {
$urlArgs[$idField] = $entity[$idField];
if (!empty($instanceId)) {
$instanceId .= '_';
}
$instanceId .= $entity[$idField];
}
$urlArgs['id'] = $instanceId;
/* commented out as it could exceed the maximum length of the 'extra' field
if (isset($entity['slug'])) {
$urlArgs['slug'] = $entity['slug'];
}*/
// perform permission check
if (!SecurityUtil::checkPermission($this->name . ':' . ucfirst($objectType) . ':', $instanceId . '::', ACCESS_OVERVIEW)) {
continue;
}
$title = $entity->getTitleFromDisplayPattern();
$description = !empty($descriptionField) ? $entity[$descriptionField] : '';
$created = isset($entity['createdDate']) ? $entity['createdDate']->format('Y-m-d H:i:s') : '';
$searchItemData = array('title' => $title, 'text' => $description, 'extra' => serialize($urlArgs), 'created' => $created, 'module' => $this->name, 'session' => $sessionId);
if (!DBUtil::insertObject($searchItemData, 'search_result')) {
return LogUtil::registerError($this->__('Error! Could not save the search results.'));
}
}
}
return true;
}
示例5: editAction
/**
* @Route("/edit", options={"expose"=true})
* @Method("GET")
* Modify aplicant information.
*
* @param Request $request
* @param integer $id
*
* Parameters passed via GET:
* --------------------------------------------------
* string uname The user name of the account for which profile information should be modified; defaults to the uname of the current user.
* dynadata array The modified profile information passed into this function in case of an error in the update function.
*
* @return RedirectResponse|string The rendered template output.
*
* @throws AccessDeniedException on failed permission check
*/
public function editAction(Request $request)
{
// Permission check
if (!$this->get('kaikmedia_gallery_module.access_manager')->hasPermission()) {
throw new AccessDeniedException();
}
$original_id = $request->query->get('original', false);
$relation_id = $request->query->get('relation', 'new');
//return when original id is not present and relation Id/new is not present
$mode = $request->query->get('mode', 'info');
$this->entityManager = ServiceUtil::getService('doctrine.entitymanager');
$settings = new Settings();
if ($mode == 'info') {
$original = $this->entityManager->getRepository('Kaikmedia\\GalleryModule\\Entity\\MediaEntity')->find($original_id);
//check if exist
//error if not found
$options['isXmlHttpRequest'] = $request->isXmlHttpRequest();
$original_form = $this->createForm('media', $original, $options);
$template = $this->renderView('KaikmediaGalleryModule:Media:item.modify.html.twig', array('form' => $original_form->createView(), 'relation' => false, 'original' => $original, 'settings' => ModUtil::getVar($this->name)));
} else {
if ($relation_id == 'new') {
$original = $this->entityManager->getRepository('Kaikmedia\\GalleryModule\\Entity\\MediaEntity')->find($original_id);
if ($original) {
$relation = new MediaRelation();
$relation->setOriginal($original);
$relation->setType($mode);
} else {
//original not found error
}
} elseif (is_numeric($relation_id)) {
$relation = $this->entityManager->getRepository('Kaikmedia\\GalleryModule\\Entity\\MediaRelationsEntity')->find($relation_id);
} else {
//relation coruppted
}
//error if not found
$options['isXmlHttpRequest'] = $request->isXmlHttpRequest();
$relation_form = $this->createForm('media_relation', $relation, $options);
$template = $this->renderView('KaikmediaGalleryModule:Features:' . $mode . '.feature.modify.html.twig', array('form' => $relation_form->createView(), 'relation' => $relation, 'original' => $relation->getOriginal(), 'previews' => $settings->getPreviewsSelect(), 'settings' => ModUtil::getVar($this->name)));
}
$response = new Response(json_encode(array('template' => $template)));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
示例6:
<?php
/**
* Project Name:
* File: bootstrap.php
*
* @author ______________________
* @copyright
* @Generated %date%
* @package %module_name%
* @generator AksiIDE, http://www.aksiide.com
*
**/
// Bootstrap - Used for global setup at module load time.
$helper = ServiceUtil::getService('doctrine_extensions');
$helper->getListener('sluggable');
$helper->getListener('standardfields');
示例7: saveValue
/**
* Saves value in data object.
*
* Called by the render when doing $render->getValues()
* Uses the group parameter to decide where to store data.
*
* @param Zikula_Form_View $view Reference to Form render object.
* @param array &$data Data object.
*
* @return void
*/
public function saveValue(Zikula_Form_View $view, &$data)
{
if ($this->enableDBUtil && $this->dataBased) {
if ($this->group == null) {
$data['__CATEGORIES__'][$this->dataField] = $this->getSelectedValue();
} else {
if (!array_key_exists($this->group, $data)) {
$data[$this->group] = array();
}
$data[$this->group]['__CATEGORIES__'][$this->dataField] = $this->getSelectedValue();
}
} else {
if ($this->enableDoctrine && $this->dataBased) {
if ($this->group == null) {
$data['Categories'][$this->dataField] = array('category_id' => $this->getSelectedValue(), 'reg_property' => $this->dataField);
} else {
if (!array_key_exists($this->group, $data)) {
$data[$this->group] = array();
}
$data[$this->group]['Categories'][$this->dataField] = array('category_id' => $this->getSelectedValue(), 'reg_property' => $this->dataField);
}
} else {
if ($this->doctrine2) {
$entity = $view->get_template_vars($this->group);
// load category from db
$em = ServiceUtil::getService('doctrine.entitymanager');
$collection = $em->getClassMetadata(get_class($entity))->getFieldValue($entity, $this->dataField);
if (!$collection) {
$collection = new \Doctrine\Common\Collections\ArrayCollection();
$em->getClassMetadata(get_class($entity))->setFieldValue($entity, $this->dataField, $collection);
}
if (is_array($this->getSelectedValue())) {
$selectedValues = $this->getSelectedValue();
} else {
$selectedValues[] = $this->getSelectedValue();
}
$selectedValues = array_combine($selectedValues, $selectedValues);
foreach ($collection->getKeys() as $key) {
$entityCategory = $collection->get($key);
if ($entityCategory->getCategoryRegistryId() == $this->registryId) {
$categoryId = $entityCategory->getCategory()->getId();
if (isset($selectedValues[$categoryId])) {
unset($selectedValues[$categoryId]);
} else {
$collection->remove($key);
}
}
}
// we do NOT flush here, as the calling module is responsible for that (Guite)
//$em->flush();
foreach ($selectedValues as $selectedValue) {
$category = $em->find('Zikula_Doctrine2_Entity_Category', $selectedValue);
$class = $em->getClassMetadata(get_class($entity))->getAssociationTargetClass($this->dataField);
$collection->add(new $class($this->registryId, $category, $entity));
}
} else {
parent::saveValue($view, $data);
}
}
}
}
示例8: __construct
/**
* constructor
*/
public function __construct()
{
$this->online = 0;
$this->depot = 0;
$this->inmenu = 1;
$this->inlist = 1;
$em = \ServiceUtil::getService('doctrine.entitymanager');
$this->author = $em->getRepository('Zikula\\UsersModule\\Entity\\UserEntity')->findOneBy(array('uid' => \UserUtil::getVar('uid')));
$this->language = 'all';
$this->layout = 'default';
$this->views = 0;
// $this->attributes = new ArrayCollection();
}
示例9: search
/**
* Executes the actual search process.
*
* @param array $args List of arguments.
*
* @return boolean
*/
public function search($args)
{
if (!SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) {
return '';
}
// ensure that database information of Search module is loaded
ModUtil::dbInfoLoad('Search');
// save session id as it is used when inserting search results below
$sessionId = session_id();
// retrieve list of activated object types
//$searchTypes = isset($args['objectTypes']) ? (array)$args['objectTypes'] : (array)FormUtil::getPassedValue('search_mediarepository_types', array(), 'GETPOST');
$searchTypes[] = 'posting';
$controllerHelper = new MUBoard_Util_Controller($this->serviceManager);
$utilArgs = array('api' => 'search', 'action' => 'search');
//$allowedTypes = $controllerHelper->getObjectTypes('api', $utilArgs);
$allowedTypes[] = 'posting';
$entityManager = ServiceUtil::getService('doctrine.entitymanager');
$currentPage = 1;
$resultsPerPage = 50;
// foreach ($searchTypes as $objectType) {
/* if (!in_array($objectType, $allowedTypes)) {
continue;
}*/
$whereArray = array();
$languageField = null;
$whereArray[] = 'title';
$whereArray[] = 'text';
/*switch ($objectType) {
case 'repository':
$whereArray[] = 'name';
$whereArray[] = 'workDirectory';
$whereArray[] = 'storageDirectory';
$whereArray[] = 'cacheDirectory';
$whereArray[] = 'uploadNamingPrefix';
$whereArray[] = 'mailRecipient';
break;
case 'mediaHandler':
$whereArray[] = 'mimeType';
$whereArray[] = 'fileType';
$whereArray[] = 'foundMimeType';
$whereArray[] = 'foundFileType';
$whereArray[] = 'handlerName';
$whereArray[] = 'title';
$whereArray[] = 'image';
break;
case 'medium':
$whereArray[] = 'title';
$whereArray[] = 'keywords';
$whereArray[] = 'description';
$whereArray[] = 'description2';
$whereArray[] = 'dateTaken';
$whereArray[] = 'placeTaken';
$whereArray[] = 'notes';
$whereArray[] = 'license';
$whereArray[] = 'areamap';
$whereArray[] = 'url';
$whereArray[] = 'mediaHandler';
$whereArray[] = 'fileUpload';
break;
case 'thumbSize':
$whereArray[] = 'name';
break;
}*/
$where = Search_Api_User::construct_where($args, $whereArray, $languageField);
$repository = $entityManager->getRepository($this->name . '_Entity_' . ucfirst($objectType));
$repository = MUBoard_Util_Model::getPostingRepository();
// get objects from database
list($entities, $objectCount) = $repository->selectWherePaginated($where, '', $currentPage, $resultsPerPage, false);
if ($objectCount == 0) {
continue;
}
$idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType));
$titleField = $repository->getTitleFieldName();
$descriptionField = $repository->getDescriptionFieldName();
foreach ($entities as $entity) {
$urlArgs = array('ot' => $objectType);
// create identifier for permission check
$instanceId = '';
foreach ($idFields as $idField) {
$urlArgs[$idField] = $entity[$idField];
if (!empty($instanceId)) {
$instanceId .= '_';
}
$instanceId .= $entity[$idField];
}
$urlArgs['id'] = $instanceId;
if (isset($entity['slug'])) {
$urlArgs['slug'] = $entity['slug'];
}
if (!SecurityUtil::checkPermission($this->name . ':' . ucfirst($objectType) . ':', $instanceId . '::', ACCESS_OVERVIEW)) {
continue;
}
$title = $titleField != '' ? $entity[$titleField] : $this->__('Item');
//.........这里部分代码省略.........
示例10: removeUserWidgets
/**
* @param integer $uid
*/
public static function removeUserWidgets($uid)
{
/* @var EntityManager $em */
$em = ServiceUtil::getService('doctrine.entitymanager');
/* @var Dashboard_Entity_Widget $widget */
$widgets = $em->getRepository('Dashboard_Entity_UserWidget')->findBy(array('uid' => $uid));
foreach ($widgets as $widget) {
$em->remove($widget);
}
$em->flush();
}