Commit cb1e559c authored by Hermann Mayer's avatar Hermann Mayer

Finished Service Structure by refactoring the fixtures class, which now uses the…

Finished Service Structure by refactoring the fixtures class, which now uses the metadata of the service handler to provide the service entities.
parent 2ce6e695
......@@ -2,13 +2,12 @@
namespace Jity\HomepageBundle\DataFixtures\ORM;
use Jity\HomepageBundle\Entity\User;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Jity\HomepageBundle\Entity\User,
Doctrine\Common\Persistence\ObjectManager,
Doctrine\Common\DataFixtures\AbstractFixture,
Doctrine\Common\DataFixtures\OrderedFixtureInterface,
Symfony\Component\DependencyInjection\ContainerAwareInterface,
Symfony\Component\DependencyInjection\ContainerInterface;
/**
* LoadUserData
......
......@@ -2,11 +2,12 @@
namespace Jity\HomepageBundle\DataFixtures\ORM;
use Jity\HomepageBundle\Entity\Service;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Jity\HomepageBundle\Entity\Service,
Doctrine\Common\Persistence\ObjectManager,
Doctrine\Common\DataFixtures\AbstractFixture,
Doctrine\Common\DataFixtures\OrderedFixtureInterface,
Symfony\Component\DependencyInjection\ContainerAwareInterface,
Symfony\Component\DependencyInjection\ContainerInterface;
/**
* LoadServiceData
......@@ -16,8 +17,22 @@ use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
* @version $id$
* @author Hermann Mayer <hermann.mayer92@gmail.com>
*/
class Load04ServiceData extends AbstractFixture implements OrderedFixtureInterface
class Load04ServiceData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
{
private $container;
/**
* setContainer
*
* @param ContainerInterface $container
* @access public
* @return void
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* load
*
......@@ -27,52 +42,27 @@ class Load04ServiceData extends AbstractFixture implements OrderedFixtureInterfa
*/
public function load(ObjectManager $manager)
{
// Build Homepage Service
$homepage = new Service();
$homepage
->setName('homepage')
->setTitle('Homepage')
->setDescription('Definiert die Homepage, den Startpunkt der Applikation.')
;
$servHandler = $this->container->get('jity_service.handler');
// Build Contact Service
$contact = new Service();
$contact
->setName('contact')
->setTitle('Kontakt')
->setDescription('Fügt ein simples Kontakt-Formular hinzu.')
;
foreach ($servHandler->getMetadata() as $name => $meta) {
// Build Impress Service
$impress = new Service();
$impress
->setName('impress')
->setTitle('Impressum')
->setDescription('Fügt ein Impressum hinzu.')
;
// Build new Service with the Metadata
$serv = new Service();
$serv
->setName($name)
->setTitle($meta['title'])
->setDescription($meta['description'])
;
// Build Blog Service
$blog = new Service();
$blog
->setName('blog')
->setTitle('Blog')
->setDescription('Fügt die Startseite eines Blogs hinzu.')
;
// Save all Groups
$manager->persist($serv);
// Save all Groups
$manager->persist($homepage);
$manager->persist($contact);
$manager->persist($impress);
$manager->persist($blog);
// Build Fixture References
$this->addReference($name . '-service', $serv);
}
// Flush to Database
$manager->flush();
// Build Fixture References
$this->addReference('homepage-service', $homepage);
$this->addReference('contact-service', $contact);
$this->addReference('impress-service', $impress);
$this->addReference('blog-service', $blog);
}
/**
......
......@@ -376,22 +376,6 @@ erreichen, oder über Google+.
->addComment($comment)
;
// Build Home Page
$test = new Article();
$test
->setTitle('Blubber Test')
->setContent('21')
->setCategory($this->getReference('default-category'))
->setSidebar($this->getReference('blog-sidebar'))
->setNavigation($this->getReference('blog-navigation'))
->setAuthor($this->getReference('admin-user'))
->setIcon('icon-font')
;
$manager->persist($test);
/*
* --------------------------------------------------------------------
*/
......
......@@ -22,7 +22,25 @@ abstract class AbstractService
* @return void
*/
abstract public function getName();
/**
* getTitle
*
* @abstract
* @access public
* @return void
*/
abstract public function getTitle();
/**
* getDescription
*
* @abstract
* @access public
* @return void
*/
abstract public function getDescription();
/**
* process
*
......
......@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
/**
* BlogController
*
* @DI\Service("jity_service.controller.blog", scope="request")
* @DI\Service("jity_service.controller.blog")
* @DI\Tag("jity_service.controller")
*
* @uses Controller
......@@ -31,6 +31,28 @@ class BlogController extends AbstractService
return 'blog';
}
/**
* getTitle
*
* @access public
* @return void
*/
public function getTitle()
{
return 'Blog Dashboard';
}
/**
* getDescription
*
* @access public
* @return void
*/
public function getDescription()
{
return 'Fügt die Startseite eines Blogs hinzu.';
}
/**
* process
*
......
......@@ -12,7 +12,7 @@ use Jity\HomepageBundle\Entity\Contact,
/**
* ContactController
*
* @DI\Service("jity_service.controller.contact", scope="request")
* @DI\Service("jity_service.controller.contact")
* @DI\Tag("jity_service.controller")
*
* @uses Controller
......@@ -32,6 +32,28 @@ class ContactController extends AbstractService
return 'contact';
}
/**
* getTitle
*
* @access public
* @return void
*/
public function getTitle()
{
return 'Kontakt Formular';
}
/**
* getDescription
*
* @access public
* @return void
*/
public function getDescription()
{
return 'Fügt ein simples Kontakt-Formular hinzu.';
}
/**
* process
*
......
......@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
/**
* HomepageController
*
* @DI\Service("jity_service.controller.homepage", scope="request")
* @DI\Service("jity_service.controller.homepage")
* @DI\Tag("jity_service.controller")
*
* @uses Controller
......@@ -31,6 +31,28 @@ class HomepageController extends AbstractService
return 'homepage';
}
/**
* getTitle
*
* @access public
* @return void
*/
public function getTitle()
{
return 'Homepage';
}
/**
* getDescription
*
* @access public
* @return void
*/
public function getDescription()
{
return 'Definiert die Homepage, den Startpunkt der Applikation.';
}
/**
* process
*
......
......@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
/**
* ImpressController
*
* @DI\Service("jity_service.controller.impress", scope="request")
* @DI\Service("jity_service.controller.impress")
* @DI\Tag("jity_service.controller")
*
* @uses Controller
......@@ -31,6 +31,28 @@ class ImpressController extends AbstractService
return 'impress';
}
/**
* getTitle
*
* @access public
* @return void
*/
public function getTitle()
{
return 'Impressum';
}
/**
* getDescription
*
* @access public
* @return void
*/
public function getDescription()
{
return 'Fügt ein Impressum hinzu.';
}
/**
* process
*
......
......@@ -9,7 +9,7 @@ use Jity\HomepageBundle\DependencyInjection\Service\AbstractService,
/**
* Handler
*
* @DI\Service("jity_service.handler", scope="request")
* @DI\Service("jity_service.handler")
*
* @version $id$
* @author Hermann Mayer <hermann.mayer92@gmail.com>
......@@ -60,5 +60,23 @@ class Handler
return $this->controller[(string)$name];
}
}
/**
* getMetadata
*
* @access public
* @return void
*/
public function getMetadata()
{
$meta = array();
foreach ($this->controller as $name => $controller) {
$meta[$name]['title'] = $controller->getTitle();
$meta[$name]['description'] = $controller->getDescription();
}
return $meta;
}
}
......@@ -31,7 +31,7 @@
<td>{{ entity.title }}</td>
<td style="text-align: center">
{% if entity.service %}
<i class="icon-ok icon-white"></i><br>{{ entity.service.title }}
<div title="{{ entity.service.description }}"><i class="icon-ok icon-white"></i><br>{{ entity.service.title }}</div>
{% else %}
<i class="icon-remove icon-white"></i>
{% endif %}
......
......@@ -194,46 +194,53 @@ $(document).ready(function() {
app.scrollTo('a[name="comments"]');
});
$(window).scroll(function (){
// Fetch current values
var position = $(window).scrollTop();
var navbarHeight = $('.navbar').height();
var helper = $('.blog-article > div > .pull-left');
var topHelper = $('#blog-navigation-top');
var page = $('.blog-article');
var pageTop = page.offset().top;
var maxTop = pageTop + page.height() - helper.height() - 40; // 20 = Margins
if ((position > navbarHeight) && (position < maxTop)) {
// User cant see the top and isnt near to the bottom
var curTop = $('.row:first').position().top - navbarHeight;
// Reset Style in favor of getting clean left-value (resize)
helper.attr('style', '');
// Calculate ne position and apply
var curLeft = helper.position().left;
var style = 'position: fixed; left: ' + curLeft + 'px; top: ' + curTop + 'px;';
helper.attr('style', style);
// Show Top-Trigger
topHelper.slideDown();
article = {
refreshNavigation: function (){
// Fetch current values
var position = $(window).scrollTop();
var navbarHeight = $('.navbar').height();
var helper = $('.blog-article > div > .pull-left');
var topHelper = $('#blog-navigation-top');
var page = $('.blog-article');
var pageTop = page.offset().top;
var maxTop = pageTop + page.height() - helper.height() - 40; // 20 = Margins
if ((position > navbarHeight) && (position < maxTop)) {
// User cant see the top and isnt near to the bottom
var curTop = $('.row:first').position().top - navbarHeight;
// Reset Style in favor of getting clean left-value (resize)
helper.attr('style', '');
// Calculate ne position and apply
var curLeft = helper.position().left;
var style = 'position: fixed; left: ' + curLeft + 'px; top: ' + curTop + 'px;';
helper.attr('style', style);
// Show Top-Trigger
topHelper.slideDown();
} else {
} else {
// User can see the top and is near to the bottom
// Remove Style and Hide Top-Trigger
topHelper.slideUp();
helper.attr('style', '');
// User can see the top and is near to the bottom
// Remove Style and Hide Top-Trigger
topHelper.slideUp();
helper.attr('style', '');
}
}
});
}
$(window).scroll(article.refreshNavigation);
comments = {
init: function() {
article.refreshNavigation();
$('textarea[data-target="#editor_modal"]').bind('focus', function(){
// Mark syncElement with a unique id
......
......@@ -33,7 +33,7 @@
<td>{{ entity.title }}</td>
<td style="text-align: center">
{% if entity.service %}
<i class="icon-ok icon-white"></i><br>{{ entity.service.title }}
<div title="{{ entity.service.description }}"><i class="icon-ok icon-white"></i><br>{{ entity.service.title }}</div>
{% else %}
<i class="icon-remove icon-white"></i>
{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment