westdc-core/Westdc/EventModel/HandleFactory.php

33 lines
674 B
PHP
Raw Normal View History

<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2014/11/10
* Time: 13:36
*/
namespace Westdc\EventModel;
use Westdc\EventModel\Handles;
2014-11-14 10:02:49 +00:00
use Westdc\Service\AbstractServiceManager;
2014-11-14 10:02:49 +00:00
class HandleFactory extends AbstractServiceManager{
2014-11-14 10:02:49 +00:00
public function get($handleName)
{
2014-11-14 10:02:49 +00:00
$config = $this->getServiceManager()->get('Config');
$appConfig = $config->get('application.ini');
$handleName = $appConfig['HandlesNamespace'] . "\\" . $handleName;
2014-11-14 10:02:49 +00:00
if(class_exists($handleName))
{
return new $handleName();
}else{
throw new \RuntimeException("Handle not exists");
2014-11-14 10:02:49 +00:00
}
}
}