| Current Path : /var/www/v3.cesa.co.za/src/CoreBundle/Services/ |
| Current File : /var/www/v3.cesa.co.za/src/CoreBundle/Services/SystemSettingGroupManager.php |
<?php
namespace App\CoreBundle\Services;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Monolog\Logger;
use App\CoreBundle\Entity\SystemSettingGroup;
/**
* System Setting Group manager
*
* @author Otto Saayman <otto@igotafrica.com>
* @package CoreBundle
* @subpackage System Setting Group
* @version 0.0.1
*/
final class SystemSettingGroupManager {
/**
* Service Container
* @var object
*/
private $container = null;
/**
* Entity manager
* @var object
*/
private $em;
/**
* Class construct
*
* @param ContainerInterface $container
* @param Logger $logger
* @return void
*/
public function __construct(
ContainerInterface $container) {
$this->setContainer($container);
$this->setEm($container->get('doctrine')->getManager('default'));
return;
}
/**
* Get Container
*
* @return ContainerInterface $container
*/
public function getContainer() {
return $this->container;
}
/**
* Set Container
*
* @param ContainerInterface $container
* @return void
*/
public function setContainer($container) {
$this->container = $container;
}
/**
* Get Entity Manager
*
* @return string
*/
public function getEm() {
return $this->em;
}
/**
* Set Container
*
* @param string $em
* @return void
*/
public function setEm($em) {
$this->em = $em;
}
/**
* Check if exists and load if not for given System Setting Group
*
* @param string $systemSettingGroupName
* @return SystemSettingGroup
*/
public function checkAndLoad($systemSettingGroupName, $isVisible = false) {
$systemSettingGroup = $this->em->getRepository(SystemSettingGroup::class)->findOneBy(array('group_name' => $systemSettingGroupName));
if (!is_object($systemSettingGroup)) {
$systemSettingGroup = new SystemSettingGroup();
$systemSettingGroup->setGroupName($systemSettingGroupName);
$systemSettingGroup->setIsVisible($isVisible);
$this->getEm()->persist($systemSettingGroup);
$this->getEm()->flush();
}
return $systemSettingGroup;
}
/**
* Get a list of all the system setting group
*
* @return array
*/
public function listAll() {
return $this->em->getRepository(SystemSettingGroup::class)
->createQueryBuilder('ssg')
->orderBy('ssg.group_name')
->getQuery()->getResult();
}
}