/** * @param $class * @param $file * @param null $oldRegistryEntry * @return bool */ public function registerClass($class, $file, $oldRegistryEntry = null) { require_once $file; $classAnnotation = $this->getRegistryConfig($class); if ($classAnnotation) { $registryEntry = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Registry')->findOneByClassName($class); $this->db->updateSchema(); if ($registryEntry === null) { $registryEntry = new \Fraym\Registry\Entity\Registry(); } $registryEntry = $this->updateRegistryEntry($registryEntry, $class, $classAnnotation); $this->createEntities($registryEntry, $classAnnotation, $oldRegistryEntry); if ($classAnnotation->onRegister) { call_user_func_array(array($this->serviceLocator->get($class), $classAnnotation->onRegister), array($classAnnotation, $oldRegistryEntry)); } return true; } return false; }
/** * @param $class * @param null $oldRegistryEntry * @return bool */ public function registerClass($class, $oldRegistryEntry = null) { $classAnnotation = $this->getRegistryConfig($class); if ($classAnnotation) { $registryEntry = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Registry')->findOneByClassName($class); if ($registryEntry === null) { $registryEntry = new \Fraym\Registry\Entity\Registry(); } else { $this->composerUpdate([$registryEntry->repositoryKey]); } // Clear cache to generate new entity folders $this->core->cache->clearAll(); $this->db->updateSchema(); $registryEntry = $this->updateRegistryEntry($registryEntry, $class, $classAnnotation); $this->createEntities($registryEntry, $classAnnotation, $oldRegistryEntry); if ($classAnnotation->onRegister) { call_user_func_array([$this->serviceLocator->get($class), $classAnnotation->onRegister], [$classAnnotation, $oldRegistryEntry]); } $this->core->cache->clearAll(); return true; } return false; }