Permalink
Browse files

Merge pull request #75 from Baachi/master

Fix some CS issues
  • Loading branch information...
2 parents 7ae50ac + b6e2e8f commit 0ece13696e912701c8cc04e77a645d038a8d9c8e @Baachi Baachi committed Mar 20, 2013
@@ -19,9 +19,10 @@
namespace Doctrine\Search;
-use Doctrine\Search\Mapping\Driver\Driver;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\ArrayCache;
+use Doctrine\Search\Mapping\ClassMetadataFactory;
+use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
/**
* Configuration SearchManager
@@ -32,17 +33,15 @@
class Configuration
{
/**
- *
- * Holds the attributes for the search configuration
- * @var array $attributes
+ * @var array
*/
private $attributes;
/**
* Gets the cache driver implementation that is used for the mapping metadata.
* (Annotation is the default)
*
- * @return Mapping\Driver\Driver
+ * @return MappingDriver
*/
public function getMetadataDriverImpl()
{
@@ -56,17 +55,17 @@ public function getMetadataDriverImpl()
/**
* Sets the driver that is used to store the class metadata .
*
- * @param Driver $concreteDriver
+ * @param MappingDriver $concreteDriver
*/
- public function setMetadataDriverImpl(Driver $concreteDriver)
+ public function setMetadataDriverImpl(MappingDriver $concreteDriver)
{
$this->attributes['concreteMetadataDriver'] = $concreteDriver;
}
/**
* Sets the cache driver that is used to cache the metadata.
*
- * @param \Doctrine\Common\Cache\Cache $concreteCache
+ * @param Cache $concreteCache
*/
public function setMetadataCacheImpl(Cache $concreteCache)
{
@@ -76,7 +75,7 @@ public function setMetadataCacheImpl(Cache $concreteCache)
/**
* Returns the cache driver that is used to cache the metadata.
*
- * @return \Doctrine\Common\Cache\Cache
+ * @return Cache
*/
public function getMetadataCacheImpl()
{
@@ -87,6 +86,7 @@ public function getMetadataCacheImpl()
* Add a new default annotation driver with a correctly configured annotation reader.
*
* @param array $paths
+ *
* @return Mapping\Driver\AnnotationDriver
*/
public function newDefaultAnnotationDriver(array $paths = array())
@@ -116,13 +116,14 @@ public function getClassMetadataFactoryName()
if (!isset($this->attributes['classMetadataFactoryName'])) {
$this->attributes['classMetadataFactoryName'] = 'Doctrine\Search\Mapping\ClassMetadataFactory';
}
+
return $this->attributes['classMetadataFactoryName'];
}
/**
* Gets the class metadata factory.
*
- * @return Doctrine\Common\AbstractClassMetadataFactory
+ * @return ClassMetadataFactory
*/
public function getClassMetadataFactory()
{
@@ -1,45 +0,0 @@
-<?php
-namespace Doctrine\Search\Listener;
-
-use Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs;
-use Doctrine\Search\SearchManager;
-use Doctrine\Search\Mapping\ClassMetadata;
-
-/**
- * Listener for MongoDB Events
- *
- * @todo: add SearchListenerInterface
- *
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
- * @author Mike Lohmann <mike.h.lohmann@googlemail.com>
- */
-
-class MongoDBSearchListener
-{
- private $searchManager;
-
- public function __construct(SearchManager $sm = null)
- {
- $this->searchManager = $sm ? : new SearchManager();
- }
-
- /**
- *
- * @param \Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs $eventargs
- * @return void
- */
- public function loadClassMetadata(LoadClassMetadataEventArgs $eventargs)
- {
- $this->searchManager->setObjectManager($eventargs->getDocumentManager());
- $reflClass = $eventargs->getClassMetadata()->getReflectionClass();
- $this->searchManager->loadClassMetadata($reflClass->getName());
- }
-
- /**
- * @return \Doctrine\Search\SearchManager
- */
- public function getSearchManager()
- {
- return $this->searchManager;
- }
-}
@@ -160,14 +160,11 @@ public function __wakeup()
// Restore ReflectionClass and properties
$this->reflClass = new \ReflectionClass($this->className);
- /*I am not sure if that is needed
- * foreach ($this->fieldMappings as $field => $mapping) {
-
+ foreach ($this->fieldMappings as $field => $mapping) {
$reflField = $this->reflClass->getProperty($field);
$reflField->setAccessible(true);
$this->reflFields[$field] = $reflField;
- }*/
-
+ }
}
/**
@@ -25,6 +25,7 @@
use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory;
use Doctrine\Common\Persistence\Mapping\ReflectionService;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as BaseClassMetadata;
+use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
/**
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
@@ -37,15 +38,24 @@
*/
class ClassMetadataFactory extends AbstractClassMetadataFactory
{
- /** The SearchManager instance */
+ /**
+ * @var SearchManager
+ */
private $sm;
- /** The Configuration instance */
+ /**
+ * @var Configuration
+ */
private $config;
- /** The used metadata driver. */
+ /**
+ * @var MappingDriver
+ */
private $driver;
+ /**
+ * {@inheritDoc}
+ */
protected function initialize()
{
$this->driver = $this->config->getMetadataDriverImpl();
@@ -72,12 +82,12 @@ public function setConfiguration(Configuration $config)
$this->config = $config;
}
-
/**
* Get the fully qualified class-name from the namespace alias.
*
* @param string $namespaceAlias
* @param string $simpleClassName
+ *
* @return string
*/
protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
@@ -93,7 +103,6 @@ protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
protected function getDriver()
{
return $this->driver;
-
}
/**
@@ -102,13 +111,13 @@ protected function getDriver()
* @param ClassMetadata $class
* @param ClassMetadata $parent
* @param bool $rootEntityFound
+ *
* @return void
*/
protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
{
//Manipulates $classMetadata;
$this->driver->loadMetadataForClass($class->getName(), $class);
-
}
/**
@@ -120,14 +129,14 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS
protected function newClassMetadataInstance($className)
{
return new ClassMetadata($className);
-
}
/**
* Wakeup reflection after ClassMetadata gets unserialized from cache.
*
- * @param ClassMetadata $class
+ * @param BaseClassMetadata $class
* @param ReflectionService $reflService
+ *
* @return void
*/
protected function wakeupReflection(BaseClassMetadata $class, ReflectionService $reflService)
@@ -27,6 +27,8 @@
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Search\Exception\UnexpectedTypeException;
+use Doctrine\Search\Mapping\ClassMetadata;
+use Doctrine\Search\Mapping\ClassMetadataFactory;
/**
* Interface for a Doctrine SearchManager class to implement.
@@ -37,50 +39,35 @@
class SearchManager
{
/**
- * @var SearchClient
+ * @var SearchClientInterface
*/
private $searchClient;
/**
- * @var ObjectManager
- */
- private $objectManager;
-
- /**
* @var Configuration $configuration
*/
private $configuration;
/**
- * @var object
+ * @var ClassMetadataFactory
*/
private $metadataFactory;
/**
- * @var object
- */
- private $annotationReader;
-
- /**
* Constructor
- *
- * @param ObjectManager $om
- * @param Configuration $conf
+ *
+ * @param Configuration $config
* @param SearchClientInterface $sc
*/
- public function __construct(Configuration $conf = null,
- SearchClientInterface $sc = null,
- Reader $reader = null)
+ public function __construct(Configuration $config, SearchClientInterface $sc)
{
- $this->configuration = $conf ? : new Configuration();
- $this->searchClient = $sc ? : new Client();
- $this->annotationReader = $reader ? : new AnnotationReader();
+ $this->configuration = $config;
+ $this->searchClient = $sc;
$this->metadataFactory = $this->configuration->getClassMetadataFactory();
$this->metadataFactory->setSearchManager($this);
$this->metadataFactory->setConfiguration($this->configuration);
$this->metadataFactory->setCacheDriver($this->configuration->getMetadataCacheImpl());
-
}
/**
@@ -92,45 +79,19 @@ public function getConfiguration()
}
/**
- * @return AnnotationReader
- */
- public function getAnnotationReader()
- {
- return $this->annotationReader;
- }
-
- /**
- * Sets the object manager
- *
- * @param ObjectManager $om
- */
- public function setObjectManager(ObjectManager $om)
- {
- $this->objectManager = $om;
- }
-
- /**
- * @return \Doctrine\Common\Persistence\ObjectManager
- */
- public function getObjectManager()
- {
- return $this->objectManager;
- }
-
- /**
* Loads class metadata for the given class
*
* @param string $className
*
- * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
+ * @return ClassMetadata
*/
public function getClassMetadata($className)
{
return $this->metadataFactory->getMetadataFor((string)$className);
}
/**
- * @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
+ * @return ClassMetadataFactory
*/
public function getClassMetadataFactory()
{
@@ -1,9 +1,9 @@
<?php
+
namespace Doctrine\Search;
final class Version
{
-
/**
* @var string
*/
@@ -21,5 +21,4 @@ static public function compare($version)
{
return version_compare($version, static::$version);
}
-
}
Oops, something went wrong.

0 comments on commit 0ece136

Please sign in to comment.