@param WorkspaceModel $model

@EXT\Route(
"/model/{model}/share/index",
name="claro_workspace_model_share_user_list"
)

@EXT\Template("ClarolineCoreBundle:Tool\workspace\parameters\model:indexShare.html.twig")
510209
public function shareModelUserListAction(WorkspaceModel $model)
    {
        $this->checkAccess($model->getWorkspace());

        return array(
            'model' => $model,
            'workspace' => $model->getWorkspace()
        );
    }
1172768
public function link(Model $model) {
        $this->getRelation($this->getAlias(get_class($model)))->link($model);

        return $this;
    }
845733
public function indexAction()
    {
        $user = $this->userService->getCurrentUser();
        $workspacesArray = [];
        /** @var Workspace $workspace */
        foreach ($this->workspaceRepository->findAll() as $workspace) {

            // FIXME: This check should be implemented through a specialized Workspace Privilege or something similar
            if ($workspace->getOwner() !== null && $workspace->getOwner() !== $user) {
                continue;
            }

            $workspaceArray = [
                'name' => $workspace->getName(),
                'title' => $workspace->getTitle(),
                'description' => $workspace->getDescription(),
                'baseWorkspace' => $workspace->getBaseWorkspace()
            ];
            if ($user !== null) {
                $workspaceArray['readonly'] = !$this->userService->currentUserCanPublishToWorkspace($workspace);
            }
            $workspacesArray[] = $workspaceArray;
        }

        $this->view->assign('workspaces', $workspacesArray);
    }
1006916
public function deleteModelAction(WorkspaceModel $model)
    {
        $this->checkAccess($model->getWorkspace());
        $id = $model->getId();
        $this->modelManager->delete($model);

        return new JsonResponse(array('id' => $id));
    }
564347
public function setAssociationCounts(Model $model) {
        $counts = array();

        foreach (array($model->hasMany, $model->hasAndBelongsToMany) as $property) {
            foreach ($property as $alias => $assoc) {
                $class = isset($assoc['with']) ? $assoc['with'] : $assoc['className'];

                $counts[$alias] = Admin::introspectModel($class)->find('count', array(
                    'conditions' => array($assoc['foreignKey'] => $model->id),
                    'contain' => false
                ));
            }
        }

        $this->Controller->set('counts', $counts);
    }
1228769
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
    {
        parent::processFilterAndSort($model);

        $eid = $this->request->getParam(\Gems_Model::EPISODE_ID);
        if ($eid) {
            $model->addFilter(['gap_id_episode' => $eid]);
        }
    }
1350709
protected function makeReferenceStrategy(Model $model)
    {
        // Get model information for the model
        $information = $this->getInformationRepository()->getByModel($model);

        // If the model is not part of the CMS, fall back
        if ( ! $information) return null;

        $strategy = $information->reference->strategy;

        if ( ! $strategy) {
            $strategy = config('cms-models.strategies.reference.default-strategy');
        }

        return $this->makeReferenceStrategyInstance($strategy);
    }
828375
public function link(Model $model)
    {
        if ( ! $this->routePrefix || ! $this->isPermitted) {
            return false;
        }

        return route($this->routePrefix . static::ROUTE_POSTFIX, [ $model->getKey() ]);
    }
1110602
public function insertLocalModel($model, $replacements = array()){
		$model = str_replace('LOCAL_NAMESPACE#', $this->localNs, $model);
		$model = str_replace('{ROOT_PATH}', ROOT_PATH, $model);
		
		foreach ($replacements as $k => $r){
			$model = str_replace($k, $r, $model);
		}

		return $this->insertModel($this->localNs, $model);
	}
133625
public function persist($model)
    {
        $class    = $this->manager->getClassMetadata(get_class($model));
        $managers = $class->getFieldManagerNames();
        $pool     = $this->manager->getPool();

        $managerName = $class->getManagerReferenceGenerator();
        $referenceModel = call_user_func(array($model, 'get' . ucfirst($managerName)));

        $pool->getManager($managerName)->persist($referenceModel);

        unset($managers[array_search($managerName, $managers)]);

        $this->models->attach($model, $managers);
    }
387356
public function deleted($model)
    {
        if (static::syncingDisabledFor($model)) {
            return;
        }

        if ($this->usesSoftDelete($model) && config('scout.soft_delete', false)) {
            $this->saved($model);
        } else {
            $model->unsearchable();
        }
    }
558275
public void addServletModel(final ServletModel model) throws NamespaceException, ServletException {
		servletLock.writeLock().lock();
		try {
            associateBundle(model.getContextModel().getVirtualHosts(), model.getContextModel().getBundle());
            for (String virtualHost:resolveVirtualHosts(model)) {
                if (servlets.get(virtualHost) == null) {
                    servlets.put(virtualHost, new HashSet<>());
                }
                if (model.getServlet() != null && servlets.get(virtualHost).contains(model.getServlet())) {
                        throw new ServletException("servlet already registered with a different alias");
                }
                if (model.getAlias() != null) {
                        final String alias = getFullPath(model.getContextModel(), model.getAlias());
                        if (aliasMapping.get(virtualHost) == null) {
                            aliasMapping.put(virtualHost, new HashMap<>());
                        }
                        if (aliasMapping.get(virtualHost).containsKey(alias)) {
                                throw new NamespaceException("alias: '" + alias + "' is already in use in this or another context");
                        }
                        aliasMapping.get(virtualHost).put(alias, model);
                }
                if (model.getServlet() != null) {
                        servlets.get(virtualHost).add(model.getServlet());
                }
                for (String urlPattern : model.getUrlPatterns()) {
                        if (servletUrlPatterns.get(virtualHost) == null) {
                            servletUrlPatterns.put(virtualHost, new HashMap<>());
                        }
                        servletUrlPatterns.get(virtualHost).put(getFullPath(model.getContextModel(), urlPattern),
                                        new UrlPattern(getFullPath(model.getContextModel(), urlPattern), model));
                }
            }
		} finally {
			servletLock.writeLock().unlock();
		}
	}
589661
public function onPreviewHtmlReport(Model $model)
    {
        $this->onReportsHistory();
        Breadcrumbs::register('logger-reports-preview-' . $model->id, function($breadcrumbs) use($model) {
            $breadcrumbs->parent('logger-reports-history');
            $breadcrumbs->push('Preview report ' . $model->name, handles('antares::logger/view/' . $model->id));
        });
        view()->share('breadcrumbs', Breadcrumbs::render('logger-reports-preview-' . $model->id));
    }
319016
public function addNodesCopyAction(WorkspaceModel $model, array $resourceNodes)
    {
        $this->checkAccess($model->getWorkspace());
        $resourceModels = $this->modelManager->addResourceNodes($model, $resourceNodes, true);
        $data = [];

        foreach ($resourceModels as $resourceModel) {
            $data[] = array(
                'resourceModelId' => $resourceModel->getId(),
                'name' => $resourceModel->getResourceNode()->getName()
            );
        }

        return new JsonResponse($data);
    }
1204546
protected function serializeModel($model)
    {
        list ($fields, $expand) = $this->getRequestedFields();
        return $model->toArray($fields, $expand);
    }
150410
protected function setModelForElements(Model $model)
    {
        $this->getElements()->each(function ($element) use ($model) {
            $element = $this->getElementContainer($element);

            if ($element instanceof WithModelInterface) {
                $element->setModel($model);
            }
        });

        return $this;
    }
1318688
protected function tree($model)
    {
        $models = Address::getAddresses($model->entity_id, $model->entity);
        return $this->renderPartial('@net/frenzel/address/views/widgets/views/_index_item', ['models' => $models]);
    }