Пометка "прочитано".

@param Request $request
@param CommentsModerateServiceContract $moderateService

@return ReadResponseContract
335402
public function read(Request $request, CommentsModerateServiceContract $moderateService): ReadResponseContract
    {
        $ids = $request->get('comments') ?? [];

        $result = $moderateService->updateRead($ids);

        return app()->makeWith(ReadResponseContract::class, compact('result'));
    }
1236266
public function saveComment(array $data,
                                string $type,
                                int $id): ?CommentModelContract
    {
        if (! isset($this->availableTypes[$type])) {
            return null;
        }

        $usersService = app()->make('InetStudio\ACL\Users\Contracts\Services\Front\UsersServiceContract');

        $request = request();
        $item = $this->availableTypes[$type]::find($id);

        if (! ($item && $item->id)) {
            return null;
        }

        $data = array_merge($data, [
            'commentable_id' => $item->id,
            'commentable_type' => get_class($item),
            'user_id' => $usersService->getUserId(),
            'name' => $usersService->getUserName($request),
            'email' => $usersService->getUserEmail($request),
        ]);

        $item = $this->saveModel($data);
        $item->saveAsRoot();

        if ($item && $item->id) {
            event(app()->makeWith('InetStudio\Comments\Contracts\Events\Front\SendCommentEventContract', [
                'object' => $item,
            ]));
        }

        return $item;
    }
1030396
public function index(CommentsDataTableServiceContract $datatablesService): IndexResponseContract
    {
        $table = $datatablesService->html();

        return app()->makeWith(IndexResponseContract::class, [
            'data' => compact('table'),
        ]);
    }
933915
public function postAction(Request $request)
    {
        $document = $this->documentManager->create(Structure::TYPE_SNIPPET);
        $form = $this->processForm($request, $document);

        return $this->handleView($form->getData());
    }
481732
public function save(Comment $comment, Request $request)
    {
        $comment
            ->fill($request->get('comment'))
            ->save();

        Alert::info(__('Comment was saved'));

        return redirect()->route('platform.systems.comments');
    }
1350083
public function CommentsForm()
    {
        $form = Injector::inst()->create(CommentForm::class, __FUNCTION__, $this);

        // hook to allow further extensions to alter the comments form
        $this->extend('alterCommentForm', $form);

        return $form;
    }
510277
public function destroy(CommentsServiceContract $commentsService, int $id = 0): DestroyResponseContract
    {
        $result = $commentsService->destroy($id);

        return app()->makeWith(DestroyResponseContract::class, [
            'result' => (!! $result),
        ]);
    }
236507
public function crudEdit(Request $request, $id)
    {
        try{
            $entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));
            $form = $this->createForm( $this->getEntityType() , $entity)->createView();
            $delete_form = $this->createDeleteForm($id)->createView();
            
            return $this->commonsResponseVars(compact('entity','form','delete_form'));
            
        }catch(\Exception $e){
          return $this->failure($e);
        }
    }
1052175
public function createAction(Request $request, $postid)
    {
        $post = $this->getPost($postid);

        $entity = new Comment();
        $entity->setPost($post);
        $entity->setAuthor($this->getCurrentAuthor());
        $form   = $this->createForm(new CommentType(), $entity);
        $form->bind($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            $this->getSession()->getFlashBag()->set('success', 'The comment has been created successfully.');

            return $this->redirect($this->generateUrl('page_or_post', array('slug' => $post->getSlug())));
        }

        return array(
            'entity' => $entity,
            'post'   => $post,
            'form'   => $form->createView(),
        );
    }
96502
public function newPagePartAction(Request $request)
    {
        $em = $this->get('doctrine.orm.entity_manager');

        $pageId = $request->get('pageid');
        $pageClassName = $request->get('pageclassname');
        $context = $request->get('context');
        $pagePartClass = $request->get('type');

        /** @var HasPagePartsInterface $page */
        $page = $em->getRepository($pageClassName)->find($pageId);

        if (false === $page instanceof HasPagePartsInterface) {
            throw new \RuntimeException(sprintf('Given page (%s:%d) has no pageparts', $pageClassName, $pageId));
        }

        $pagePartConfigurationReader = $this->container->get('kunstmaan_page_part.page_part_configuration_reader');
        $pagePartAdminConfigurators = $pagePartConfigurationReader->getPagePartAdminConfigurators($page);

        $pagePartAdminConfigurator = null;
        foreach ($pagePartAdminConfigurators as $ppac) {
            if ($context == $ppac->getContext()) {
                $pagePartAdminConfigurator = $ppac;
            }
        }

        if (is_null($pagePartAdminConfigurator)) {
            throw new \RuntimeException(sprintf('No page part admin configurator found for context "%s".', $context));
        }

        $pagePartAdmin = new PagePartAdmin($pagePartAdminConfigurator, $em, $page, $context, $this->container);
        /** @var PagePartInterface $pagePart */
        $pagePart = new $pagePartClass();

        if (false === $pagePart instanceof PagePartInterface) {
            throw new \RuntimeException(sprintf(
                'Given pagepart expected to implement PagePartInterface, %s given',
                $pagePartClass
            ));
        }

        $formFactory = $this->container->get('form.factory');
        $formBuilder = $formFactory->createBuilder(FormType::class);
        $pagePartAdmin->adaptForm($formBuilder);
        $id = 'newpp_' . time();

        $data = $formBuilder->getData();
        $data['pagepartadmin_' . $id] = $pagePart;

        $formBuilder->add('pagepartadmin_' . $id, $pagePart->getDefaultAdminType());
        $formBuilder->setData($data);
        $form = $formBuilder->getForm();
        $formview = $form->createView();
        $extended = $this->getParameter('kunstmaan_page_part.extended');

        return [
            'id' => $id,
            'form' => $formview,
            'pagepart' => $pagePart,
            'pagepartadmin' => $pagePartAdmin,
            'page' => $pagePartAdmin->getPage(),
            'editmode' => true,
            'extended' => $extended,
        ];
    }
433489
public function get($commentId, array $params = array())
    {
        $endpoint = '/admin/comments/'.$commentId.'.json';
        $response = $this->request($endpoint);
        return $this->createObject(Comment::class, $response['comment']);
    }
931583
public function commentPermalink(Request $request, CommentInterface $comment) {
    if ($entity = $comment->getCommentedEntity()) {
      // Check access permissions for the entity.
      /* @var \Drupal\Core\Entity\Entity $entity */
      if (!$entity->access('view')) {
        throw new AccessDeniedHttpException();
      }
      /* @var \Drupal\Core\Url $url */
      if ($url = $entity->urlInfo('canonical')) {
        // Redirect the user to the correct entity.
        return $this->redirectToOriginalEntity($url, $comment, $entity);
      }
    }
    throw new NotFoundHttpException();
  }
461891
public function postRequest( Request $request ) {
		$response = $this->getClient()->request(
			'POST',
			$this->apiUrl,
			$this->getClientRequestOptions( $request, $this->getPostRequestEncoding( $request ) )
		);

		return $this->decodeResponse( $response );
	}
912616
public function newAction(Request $request)
    {
        /** @var ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_CREATE);

        /** @var PluginConfigurator $pluginConfigurator */
        $pluginConfigurator = $configuratorFactory->getConfigurator(PluginConfigurator::class);
        $template = $pluginConfigurator->isBulkInsertEnabled() ? $crudConfigurator->getTemplate()->getBulkCreate() : $crudConfigurator->getTemplate()->getCreate();

        $modelClass = $crudConfigurator->getCrud()->getModelClass();
        $model = new $modelClass();
        $form = $crudConfigurator->getForm($model);

        return $this->createOrUpdate($request, $model, $form, Constants::ACTION_CREATE, $template);
    }
346336
public function comments()
    {
        if (is_null($this->commentRequests)) {
            $this->commentRequests = new CommentRequests($this->client);
        }

        return $this->commentRequests;
    }
1249203
public function update(CommentRequest $request, Comment $comment)
    {
        try {
            $attributes = $request->all();

            $comment->update($attributes);
            return $this->response->message(trans('messages.success.updated', ['Module' => trans('news::comment.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('news/comment/' . $comment->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('news/comment/' . $comment->getRouteKey()))
                ->redirect();
        }

    }
611672
protected function parseContentRequest(Request $request)
    {
        return $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type'), 'Url' => $request->getPathInfo()),
                $request->getContent()
            )
        );
    }