getId() public method

public getId ( )
コード例 #1
0
 /**
  * @return int
  */
 public function delete(User $user, Post $post)
 {
     $conn = $this->_em->getConnection();
     $statement = $conn->prepare('DELETE FROM post_vote WHERE user_id = :user_id AND post_id = :post_id');
     $statement->bindValue('user_id', $user->getId());
     $statement->bindValue('post_id', $post->getId());
     return $statement->execute();
 }
コード例 #2
0
 protected function upload(Post $entity)
 {
     if (null === $entity->getFile()) {
         return;
     }
     // check if we have an old image
     if (null !== $entity->getTemp()) {
         // delete the old image
         unlink($entity->getTemp());
         // clear the temp image path
         $entity->setTemp(null);
     }
     $entity->getFile()->move($entity->getUploadRootDir() . '/' . $entity->getId(), $entity->getImageName() . '.' . $entity->getFile()->guessExtension());
     $entity->setFile(null);
 }
コード例 #3
0
 /**
  * Creates a form to delete a Post entity by id.
  *
  * This is necessary because browsers don't support HTTP methods different
  * from GET and POST. Since the controller that removes the blog posts expects
  * a DELETE method, the trick is to create a simple form that *fakes* the
  * HTTP DELETE method.
  * See http://symfony.com/doc/current/cookbook/routing/method_parameters.html.
  *
  * @param Post $post The post object
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Post $post)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('super_admin_post_delete', array('id' => $post->getId())))->setMethod('DELETE')->getForm();
 }
コード例 #4
0
ファイル: FormManager.php プロジェクト: maximzh/Blog
 public function createPostDeleteForm(Post $post)
 {
     //$builder = $this->formFactory->createBuilder();
     $form = $this->builder->setAction($this->router->generate('remove_post', array('id' => $post->getId())))->setMethod('DELETE')->add('submit', SubmitType::class, ['label' => ' ', 'attr' => ['class' => 'glyphicon glyphicon-trash btn-link']])->getForm();
     return $form;
 }
コード例 #5
0
    public function updateTotalVotes(Post $post)
    {
        $conn = $this->getEntityManager()->getConnection();
        $sql = '
        UPDATE
            post

        LEFT JOIN (
            SELECT post_id, COUNT(*) AS total FROM post_vote WHERE post_id = :post_id_1
        ) AS upvote ON upvote.post_id = post.id

        SET
            upvote_total = upvote.total

        WHERE
            post.id = :post_id_2
	    ';
        $statement = $conn->prepare($sql);
        if ($post->getId()) {
            $statement->bindValue('post_id_1', $post->getId());
            $statement->bindValue('post_id_2', $post->getId());
        }
        return $statement->execute();
    }
コード例 #6
0
ファイル: PostController.php プロジェクト: 0TshELn1ck/blog
 /**
  * Creates a form to delete a Post entity.
  *
  * @param Post $post The Post entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Post $post)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('admin_post_delete', array('id' => $post->getId())))->setMethod('DELETE')->add('submit', SubmitType::class, ['label' => ' ', 'attr' => ['class' => 'btn btn-xs btn-danger ace-icon fa fa-trash-o bigger-120']])->getForm();
 }
コード例 #7
0
 /**
  * Creates a form to delete a Post entity.
  *
  * @param Post $post The Post entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Post $post)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('cabinet_post_delete', array('id' => $post->getId())))->setMethod('DELETE')->add('submit', SubmitType::class, ['label' => ' ', 'attr' => ['class' => 'glyphicon glyphicon-trash btn-link']])->getForm();
 }
コード例 #8
0
 /**
  * @return int|null
  *
  * @Serializer\VirtualProperty()
  */
 public function getPostId()
 {
     return null !== $this->post ? $this->post->getId() : null;
 }
コード例 #9
0
 /**
  * {@inheritDoc}
  */
 public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) parent::getId();
     }
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
     return parent::getId();
 }
コード例 #10
0
 /**
  * Creates a form to delete a Post entity.
  *
  * @param Post $post The Post entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Post $post)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('_delete', array('id' => $post->getId())))->setMethod('DELETE')->getForm();
     return json_encode($post->getId());
     //for json
 }