Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 4669ec7ebb5b31599b398b108b6ccc7eafe5974b @rande rande committed May 17, 2011
@@ -0,0 +1,34 @@
+<?php
+
+/*
+ * This file is part of the Sonata package.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sonata\UserBundle\Admin\Entity;
+
+use Sonata\AdminBundle\Admin\Admin;
+
+class GroupAdmin extends Admin
+{
+ protected $list = array(
+ 'name' => array('identifier' => true),
+ 'roles'
+ );
+
+ protected $form = array(
+ 'name',
+// 'roles'
+ );
+
+ public function getNewInstance()
+ {
+ $class = $this->getClass();
+
+ return new $class('', array());
+ }
+}
@@ -0,0 +1,61 @@
+<?php
+
+/*
+ * This file is part of the Sonata package.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sonata\UserBundle\Admin\Entity;
+
+use Sonata\AdminBundle\Admin\Admin;
+
+class UserAdmin extends Admin
+{
+
+ protected $list = array(
+ 'username' => array('identifier' => true),
+ 'email',
+ 'enabled',
+ 'locked',
+ 'createdAt',
+ );
+
+ protected $form = array(
+ 'username',
+ 'email',
+ 'enabled',
+ 'plainPassword' => array('type' => 'string'),
+ 'locked',
+ 'expired',
+ 'credentialsExpired',
+ 'credentialsExpireAt',
+ 'groups'
+ );
+
+ protected $formGroups = array(
+ 'General' => array(
+ 'fields' => array('username', 'email', 'plainPassword')
+ ),
+ 'Groups' => array(
+ 'fields' => array('groups')
+ ),
+ 'Management' => array(
+ 'fields' => array('locked', 'expired', 'enabled', 'credentialsExpired', 'credentialsExpireAt')
+ )
+ );
+
+ protected $formOptions = array(
+ 'validation_groups' => 'admin'
+ );
+
+ protected $filter = array(
+ 'username',
+ 'locked',
+ 'email',
+ 'id',
+ );
+}
@@ -0,0 +1,60 @@
+<?php
+/*
+ * This file is part of the Sonata project.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+
+namespace Sonata\UserBundle\DependencyInjection;
+
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\Config\Resource\FileResource;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\Config\FileLocator;
+
+/**
+ *
+ * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ */
+class SonataUserExtension extends Extension
+{
+
+ /**
+ * Loads the url shortener configuration.
+ *
+ * @param array $config An array of configuration settings
+ * @param ContainerBuilder $container A ContainerBuilder instance
+ */
+ public function load(array $config, ContainerBuilder $container)
+ {
+ $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader->load('admin_orm.xml');
+ }
+
+ /**
+ * Returns the base path for the XSD files.
+ *
+ * @return string The XSD base path
+ */
+ public function getXsdValidationBasePath()
+ {
+ return __DIR__.'/../Resources/config/schema';
+ }
+
+ public function getNamespace()
+ {
+ return 'http://www.sonata-project.org/schema/dic/page';
+ }
+
+ public function getAlias()
+ {
+ return "sonata_user";
+ }
+}
@@ -0,0 +1,23 @@
+<?php
+/*
+ * This file is part of the Sonata project.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+
+namespace Sonata\UserBundle\Entity;
+
+use FOS\UserBundle\Entity\Group as AbstractedGroup;
+
+class BaseGroup extends AbstractedGroup
+{
+
+ public function __toString()
+ {
+ return $this->getName();
+ }
+}
@@ -0,0 +1,31 @@
+<?php
+/*
+ * This file is part of the Sonata project.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+
+namespace Sonata\UserBundle\Entity;
+
+use FOS\UserBundle\Entity\User as AbstractedUser;
+
+class BaseUser extends AbstractedUser
+{
+
+ /**
+ * @return \DateTime
+ */
+ public function getCredentialsExpireAt()
+ {
+ return $this->credentialsExpireAt;
+ }
+
+ public function __toString()
+ {
+ return $this->getUsername();
+ }
+}
21 LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2010 thomas.rabaix@sonata-project.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,4 @@
+# Integrate the FOS/UserBundle into the Sonata Project
+
+ - AdminBundle : add user and group management
+ - EasyExtends : allows to generate Application level model
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<container xmlns="http://symfony.com/schema/dic/services"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+ <parameters>
+ <!-- USER -->
+ <parameter key="sonata.user.admin.user.class">Sonata\UserBundle\Admin\Entity\UserAdmin</parameter>
+ <parameter key="sonata.user.admin.user.controller"></parameter>
+ <parameter key="sonata.user.admin.user.entity">Application\Sonata\UserBundle\Entity\User</parameter>
+
+ <!-- GROUP -->
+ <parameter key="sonata.user.admin.group.class">Sonata\UserBundle\Admin\Entity\GroupAdmin</parameter>
+ <parameter key="sonata.user.admin.group.controller"></parameter>
+ <parameter key="sonata.user.admin.group.entity">Application\Sonata\UserBundle\Entity\Group</parameter>
+ </parameters>
+
+ <services>
+ <service id="sonata.user.admin.user" class="%sonata.user.admin.user.class%">
+ <tag name="sonata.admin" manager_type="orm" group="fos_user" />
+ <argument />
+ <argument>%sonata.user.admin.user.entity%</argument>
+ <argument />
+ </service>
+
+ <service id="sonata.user.admin.group" class="%sonata.user.admin.group.class%">
+ <tag name="sonata.admin" manager_type="orm" group="fos_user"/>
+ <argument />
+ <argument>%sonata.user.admin.group.entity%</argument>
+ <argument />
+ </service>
+ </services>
+
+</container>
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
+ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
+
+ <entity name="Application\Sonata\UserBundle\Entity\Group" table="fos_user_group">
+
+ <id name="id" column="id" type="integer">
+ <generator strategy="AUTO" />
+ </id>
+
+ </entity>
+
+</doctrine-mapping>
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
+ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
+
+ <entity name="Application\Sonata\UserBundle\Entity\User" table="fos_user_user">
+
+ <id name="id" column="id" type="integer">
+ <generator strategy="AUTO" />
+ </id>
+
+ <many-to-many target-entity="Group" field="groups">
+ <join-table name="fos_user_user_group">
+ <join-columns>
+ <join-column name="user_id" referenced-column-name="id" />
+ </join-columns>
+ <inverse-join-columns>
+ <join-column name="group_id" referenced-column-name="id" />
+ </inverse-join-columns>
+ </join-table>
+ </many-to-many>
+
+ </entity>
+
+</doctrine-mapping>
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
+ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
+
+ <mapped-superclass name="Sonata\UserBundle\Entity\Group">
+
+
+ </mapped-superclass>
+
+</doctrine-mapping>
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
+ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
+
+ <mapped-superclass name="Sonata\UserBundle\Entity\User">
+
+ </mapped-superclass>
+
+</doctrine-mapping>
@@ -0,0 +1,26 @@
+<?php
+/*
+ * This file is part of the Sonata project.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sonata\UserBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Sonata\PageBundle\DependencyInjection\AddBlockServicePass;
+
+class SonataUserBundle extends Bundle
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function getParent()
+ {
+ return 'FOSUserBundle';
+ }
+}

0 comments on commit 4669ec7

Please sign in to comment.