本文整理汇总了PHP中AppBundle\Entity\Post::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::getId方法的具体用法?PHP Post::getId怎么用?PHP Post::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\Post
的用法示例。
在下文中一共展示了Post::getId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* @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: upload
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: createDeleteForm
/**
* 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: createPostDeleteForm
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: updateTotalVotes
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: createDeleteForm
/**
* 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: getPostId
/**
* @return int|null
*
* @Serializer\VirtualProperty()
*/
public function getPostId()
{
return null !== $this->post ? $this->post->getId() : null;
}
示例8: getId
/**
* {@inheritDoc}
*/
public function getId()
{
if ($this->__isInitialized__ === false) {
return (int) parent::getId();
}
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
return parent::getId();
}
示例9: createDeleteForm
/**
* 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
}