-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
45 changed files
with
2,027 additions
and
222 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.buildpath | ||
.project | ||
.settings/ | ||
.DS_Store | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright (c) 2005-2014, Zend Technologies USA, Inc. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of Zend Technologies USA, Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/Meeting for the canonical source repository | ||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Meeting; | ||
|
||
use Zend\ModuleManager\Feature\AutoloaderProviderInterface; | ||
use Zend\Mvc\ModuleRouteListener; | ||
use Zend\Mvc\MvcEvent; | ||
|
||
class Module implements AutoloaderProviderInterface | ||
{ | ||
public function getAutoloaderConfig() | ||
{ | ||
return array( | ||
'Zend\Loader\ClassMapAutoloader' => array( | ||
__DIR__ . '/autoload_classmap.php', | ||
), | ||
'Zend\Loader\StandardAutoloader' => array( | ||
'namespaces' => array( | ||
// if we're in a namespace deeper than one level we need to fix the \ in the path | ||
__NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/' , __NAMESPACE__), | ||
), | ||
), | ||
); | ||
} | ||
|
||
public function getConfig() | ||
{ | ||
return include __DIR__ . '/config/module.config.php'; | ||
} | ||
|
||
public function onBootstrap(MvcEvent $e) | ||
{ | ||
// You may not need to do this if you're doing it elsewhere in your | ||
// application | ||
$eventManager = $e->getApplication()->getEventManager(); | ||
$moduleRouteListener = new ModuleRouteListener(); | ||
$moduleRouteListener->attach($eventManager); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Sample, meeting module for use with the ZF2 MVC layer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
// Generated by ZF2's ./bin/classmap_generator.php | ||
return array( | ||
'Meeting\Module' => __DIR__ . '/Module.php', | ||
'Meeting\Controller\Main' => __DIR__ . '/src/Meeting/Controller/Main.php', | ||
'MeetingTest\Framework\TestCase' => __DIR__ . '/tests/Meeting/Framework/TestCase.php', | ||
'MeetingTest\SampleTest' => __DIR__ . '/tests/Meeting/SampleTest.php', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
return function ($class) { | ||
static $map; | ||
if (!$map) { | ||
$map = include __DIR__ . '/autoload_classmap.php'; | ||
} | ||
|
||
if (!isset($map[$class])) { | ||
return false; | ||
} | ||
return include $map[$class]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
spl_autoload_register(include __DIR__ . '/autoload_function.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
return array( | ||
'controllers' => array( | ||
'invokables' => array( | ||
'Meeting\Controller\Main' => 'Meeting\Controller\Main', | ||
), | ||
), | ||
'router' => array( | ||
'routes' => array( | ||
'meeting' => array( | ||
'type' => 'Literal', | ||
'options' => array( | ||
// Change this to something specific to your module | ||
'route' => '/meeting', | ||
'defaults' => array( | ||
// Change this value to reflect the namespace in which | ||
// the controllers for your module are found | ||
'__NAMESPACE__' => 'Meeting\Controller', | ||
'controller' => 'Main', | ||
'action' => 'index', | ||
), | ||
), | ||
'may_terminate' => true, | ||
'child_routes' => array( | ||
// This route is a sane default when developing a module; | ||
// as you solidify the routes for your module, however, | ||
// you may want to remove it and replace it with more | ||
// specific routes. | ||
'default' => array( | ||
'type' => 'Segment', | ||
'options' => array( | ||
'route' => '/[:controller[/:action][/:id]]', | ||
'constraints' => array( | ||
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', | ||
'action' => '[a-zA-Z][a-zA-Z0-9_-]*', | ||
'id' => '[0-9]+', | ||
), | ||
'defaults' => array( | ||
), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
'view_manager' => array( | ||
'template_path_stack' => array( | ||
'Meeting' => __DIR__ . '/../view', | ||
), | ||
), | ||
'doctrine' => array( | ||
'driver' => array( | ||
'meeting_entity' => array( | ||
'class' =>'Doctrine\ORM\Mapping\Driver\AnnotationDriver', | ||
'cache' => 'array', | ||
'paths' => array(__DIR__ . '/../src/Meeting/Entity') | ||
), | ||
|
||
'orm_default' => array( | ||
'drivers' => array( | ||
'Meeting\Entity' => 'meeting_entity' | ||
) | ||
))), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/Meeting for the canonical source repository | ||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Meeting\Controller; | ||
|
||
use Zend\Mvc\Controller\AbstractActionController; | ||
use Meeting\Entity\Meeting; | ||
use User\Entity\Student; | ||
use School\Entity\School; | ||
use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator; | ||
use Doctrine\ORM; | ||
use Meeting\Form\MeetingForm; | ||
|
||
class Main extends AbstractActionController | ||
{ | ||
/** | ||
* @var Doctrine\ORM\EntityManager | ||
*/ | ||
protected $em; | ||
|
||
/** | ||
* @var ZfcUserAuthService | ||
*/ | ||
protected $_auth; | ||
|
||
public function indexAction() | ||
{ | ||
$userId = 0; | ||
$auth = $this->getAuth(); | ||
if (!empty($auth) && $auth->hasIdentity()) { | ||
$userId = $auth->getIdentity()->getId(); | ||
} | ||
|
||
$meetingId = (int) $this->params()->fromRoute("id", 0); | ||
$mode = "edit"; | ||
$leading = null; | ||
$organizer = null; | ||
$meeting = $this->getEntityManager()->find('Meeting\Entity\Meeting', $meetingId); | ||
if (!$meeting instanceof Meeting) { | ||
$meeting = new Meeting(); | ||
$leading = new Student(); | ||
$organizer = new School(); | ||
$mode = "add"; | ||
} else { | ||
$leading = $this->getEntityManager()->find('User\Entity\Student', $meeting->getLeadingId()); | ||
$organizer = $this->getEntityManager()->find('School\Entity\School', $meeting->getSchoolId()); | ||
} | ||
|
||
$readonly = ($userId == $organizer->getUserId()); | ||
$form = new MeetingForm($this->getEntityManager(), $readonly); | ||
$hydrator = new DoctrineHydrator($this->getEntityManager(), get_class($meeting)); | ||
$form->setHydrator($hydrator); | ||
|
||
//bind object to form | ||
$form->bind($meeting); | ||
$form->get('id')->setValue($meetingId); | ||
if ($mode == "add") { | ||
$form->get('submit')->setValue('Add'); | ||
} else { | ||
if (!empty($leading)) | ||
$form->get('leading')->setValue($leading->getName()); | ||
if (!empty($organizer)) | ||
$form->get('school')->setValue($organizer->getName()); | ||
$form->get('timeStart')->setValue($meeting->getTimeStart()->format('d.m.y h:m')); | ||
$form->get('timeStop')->setValue($meeting->getTimeStop()->format('d.m.y h:m')); | ||
$form->get('submit')->setAttribute('value', 'Save'); | ||
} | ||
|
||
$request = $this->getRequest(); | ||
if ($request->isPost()) { | ||
$form->setData($request->getPost()); | ||
|
||
if ($form->isValid()) { | ||
if ($mode == "add") { | ||
$this->getEntityManager()->persist($meeting); | ||
$msg = 'Add new meeting'; | ||
} else { | ||
$msg = 'Edit meeting'; | ||
} | ||
$this->getEntityManager()->flush(); | ||
$this->FlashMessenger()->setNamespace(\Zend\Mvc\Controller\Plugin\FlashMessenger::NAMESPACE_INFO); | ||
// Redirect to list of albums | ||
return $this->redirect()->toRoute('meeting/default', array('controller' => 'main', 'action' => 'index', 'id' => $meetingId)); | ||
} | ||
} | ||
return array('form' => $form); | ||
} | ||
|
||
public function fooAction() | ||
{ | ||
// This shows the :controller and :action parameters in default route | ||
// are working when you browse to /module-specific-root/main/foo | ||
return array(); | ||
} | ||
|
||
/** | ||
* @return array|object|Doctrine\ORM\EntityManager | ||
*/ | ||
public function getEntityManager() | ||
{ | ||
if (null == $this->em) { | ||
$this->em = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager'); | ||
} | ||
return $this->em; | ||
} | ||
|
||
/** | ||
* @return array|object|ZfcUserAuthService | ||
*/ | ||
public function getAuth() { | ||
if (!$this->_auth) { | ||
$this->_auth = $this->zfcUserAuthentication(); | ||
} | ||
return $this->_auth; | ||
} | ||
|
||
} |
Oops, something went wrong.