Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
9 src/Paars/Bundle/TradeBundle/Controller/ArticleController.php
@@ -19,24 +19,25 @@ class ArticleController extends Controller
/**
* Finds and displays a Article entity.
*
- * @Route("/{id}/show", name="trade_show")
+ * @Route("/{category_slug}/{slug}", name="trade_article")
* @Template()
*/
- public function showAction($id)
+ public function showAction($category_slug, $slug)
{
$em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository('PaarsTradeBundle:Article')->find($id);
+ $entity = $em->getRepository('PaarsTradeBundle:Article')->findBySlug($slug);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Article entity.');
}
- $deleteForm = $this->createDeleteForm($id);
+ $deleteForm = $this->createDeleteForm($entity->getId());
return array(
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
+ 'category_slug' => $category_slug,
);
}
View
56 src/Paars/Bundle/TradeBundle/DataFixtures/ORM/LoadArticleData.php
@@ -0,0 +1,56 @@
+<?php
+
+namespace Paars\Bundle\TradeBundle\DataFixtures\ORM;
+
+use Doctrine\Common\Persistence\ObjectManager;
+use Doctrine\Common\DataFixtures\AbstractFixture;
+use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
+use Paars\Bundle\TradeBundle\Entity\Article;
+use Paars\Bundle\UserBundle\Entity\User;
+use Paars\Bundle\TradeBundle\Entity\Category;
+
+class LoadArticleData extends AbstractFixture implements OrderedFixtureInterface
+{
+ public function load(ObjectManager $manager)
+ {
+ $admin = $manager->merge($this->getReference('admin-user'));
+ $user = $manager->merge($this->getReference('user-user'));
+
+ $cfc = $manager->merge($this->getReference('cat-fc'));
+ $cservice = $manager->merge($this->getReference('cat-service'));
+ $cpc = $manager->merge($this->getReference('cat-computer'));
+
+ $bra = $this->createArticle("Wonderbra", "Wonderbra der Größe 75C in giftgrün <3", $admin, $cfc);
+ $manager->persist($bra);
+
+ $skirt = $this->createArticle("Miniskirt", "Small black miniskirt from velvet.\nHas red accents", $user, $cfc);
+ $manager->persist($skirt);
+
+ $macbook = $this->createArticle("Macbook Pro", "Da läuft auch drupal drauf!", $admin, $cpc);
+ $manager->persist($macbook);
+
+ $clean = $this->createArticle("Putze", "Will Putze.\nbin zu faul\nzahle mit sex", $admin, $cservice)
+ ->setType(Article::TYPE_REQUEST);
+ $manager->persist($clean);
+
+ $manager->flush();
+ }
+
+ private function createArticle($title, $content, User $user, Category $cat) {
+ $art = new Article();
+ $art
+ ->setTitle($title)
+ ->setContent($content)
+ ->setCategory($cat)
+ ->setType(Article::TYPE_OFFER)
+ ->setStatus(2)
+ ->applyUserSettings($user)
+ ;
+ return $art;
+ }
+
+ public function getOrder()
+ {
+ return 20; // the order in which fixtures will be loaded
+ }
+}
View
26 src/Paars/Bundle/TradeBundle/Entity/Article.php
@@ -53,7 +53,7 @@ class Article
/**
* @var string $thumb
*
- * @ORM\Column(name="thumb", type="string", length=255)
+ * @ORM\Column(name="thumb", type="string", length=255, nullable=true)
*/
private $thumb;
@@ -212,7 +212,7 @@ protected function getUploadRootDir()
protected function getUploadDir()
{
// get rid of the __DIR__ so it doesn't screw when displaying uploaded doc/image in the view.
- return 'images/thumbnails';
+ return 'images/thumbnails/';
}
public function getFile() {
@@ -563,4 +563,26 @@ public function getUser()
{
return $this->user;
}
+
+ /**
+ * Set streetno
+ *
+ * @param string $streetno
+ * @return Article
+ */
+ public function setStreetno($streetno)
+ {
+ $this->streetno = $streetno;
+ return $this;
+ }
+
+ /**
+ * Get streetno
+ *
+ * @return string
+ */
+ public function getStreetno()
+ {
+ return $this->streetno;
+ }
}
View
11 src/Paars/Bundle/TradeBundle/Entity/ArticleRepository.php
@@ -12,4 +12,13 @@
*/
class ArticleRepository extends EntityRepository
{
-}
+ public function findBySlug($slug){
+ return $this
+ ->createQueryBuilder('a')
+ ->where('a.slug = :slug')
+ ->setParameter('slug', $slug)
+ ->getQuery()
+ ->getOneOrNullResult()
+ ;
+ }
+}
View
30 src/Paars/Bundle/TradeBundle/Resources/views/Article/show.html.twig
@@ -14,14 +14,6 @@
<td>{{ entity.type }}</td>
</tr>
<tr>
- <th>Categories_id</th>
- <td>{{ entity.categoriesid }}</td>
- </tr>
- <tr>
- <th>User_id</th>
- <td>{{ entity.userid }}</td>
- </tr>
- <tr>
<th>Thumb</th>
<td>{{ entity.thumb }}</td>
</tr>
@@ -31,19 +23,7 @@
</tr>
<tr>
<th>Content</th>
- <td>{{ entity.content }}</td>
- </tr>
- <tr>
- <th>Created_at</th>
- <td>{{ entity.createdat|date('Y-m-d H:i:s') }}</td>
- </tr>
- <tr>
- <th>Updated_at</th>
- <td>{{ entity.updatedat|date('Y-m-d H:i:s') }}</td>
- </tr>
- <tr>
- <th>Freecycle</th>
- <td>{{ entity.freecycle }}</td>
+ <td>{{ entity.content | nl2br }}</td>
</tr>
<tr>
<th>Status</th>
@@ -58,8 +38,8 @@
<td>{{ entity.street }}</td>
</tr>
<tr>
- <th>Number</th>
- <td>{{ entity.number }}</td>
+ <th>streetno</th>
+ <td>{{ entity.streetno }}</td>
</tr>
<tr>
<th>City</th>
@@ -74,7 +54,7 @@
<ul class="record_actions">
<li>
- <a href="{{ path('trade') }}">
+ <a href="{{ path('trade_category', {"slug": category_slug}) }}">
Back to the list
</a>
</li>
@@ -90,4 +70,4 @@
</form>
</li>
</ul>
-{% endblock %}
+{% endblock %}
View
31 src/Paars/Bundle/TradeBundle/Resources/views/Category/show.html.twig
@@ -20,6 +20,37 @@
<div>
<h2>Artikel</h2>
+
+ <table>
+ <thead>
+ <tr>
+ <th>Thumbnail</th>
+ <th>Objekt</th>
+ <th>Aktionen</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for article in category.articles %}
+ <tr>
+ <td>
+ {% if article.thumb %}
+ <img src="{{ article.webThumb }}" />
+ {% else %}
+ X
+ {% endif %}
+ </td>
+ <td>{{ article.title }}</td>
+ <td>
+ <a href="{{ path("trade_article", {"category_slug": category.slug, "slug": article.slug}) }}">Details</a>
+ </td>
+ </tr>
+ {% else %}
+ <tr>
+ <td colspan="3">Keine Artikel :(</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
</div>
{% endblock %}

No commit comments for this range

Something went wrong with that request. Please try again.