[kateglo] r475 committed - Dependency Injection set up singleton

2 views
Skip to first unread message

kat...@googlecode.com

unread,
Jan 25, 2012, 11:42:07 AM1/25/12
to kat...@googlegroups.com
Revision: 475
Author: arthur.purnama
Date: Wed Jan 25 08:41:07 2012
Log: Dependency Injection set up singleton
http://code.google.com/p/kateglo/source/detail?r=475

Modified:
/branches/kateglox/.idea/workspace.xml
/branches/kateglox/application/configs/Binder.php
/branches/kateglox/application/daos/Meaning.php
/branches/kateglox/application/daos/interfaces/Meaning.php
/branches/kateglox/application/services/Meaning.php

=======================================
--- /branches/kateglox/.idea/workspace.xml Tue Jan 24 11:10:21 2012
+++ /branches/kateglox/.idea/workspace.xml Wed Jan 25 08:41:07 2012
@@ -5,8 +5,11 @@
</component>
<component name="ChangeListManager">
<list default="true" readonly="true"
id="91a7700a-3500-457a-96ed-4f7a08fd1085" name="Default" comment="">
- <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/.idea/kateglo.iml"
afterPath="$PROJECT_DIR$/.idea/kateglo.iml" />
<change type="MODIFICATION"
beforePath="$PROJECT_DIR$/.idea/workspace.xml"
afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/application/configs/Binder.php"
afterPath="$PROJECT_DIR$/application/configs/Binder.php" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/application/daos/Meaning.php"
afterPath="$PROJECT_DIR$/application/daos/Meaning.php" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/application/daos/interfaces/Meaning.php"
afterPath="$PROJECT_DIR$/application/daos/interfaces/Meaning.php" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/application/services/Meaning.php"
afterPath="$PROJECT_DIR$/application/services/Meaning.php" />
</list>
<ignored path="kateglo.iws" />
<ignored path=".idea/workspace.xml" />
@@ -37,15 +40,24 @@
</provider>
</entry>
</file>
- <file leaf-file-name="Type.js" pinned="false" current="true"
current-in-tab="true">
+ <file leaf-file-name="Type.js" pinned="false" current="false"
current-in-tab="false">
<entry
file="file://$PROJECT_DIR$/public/javascripts/cpanel/modules/entry/forms/Type.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="28" column="56" selection-start="1302"
selection-end="1302" vertical-scroll-proportion="0.019252548">
+ <state line="28" column="56" selection-start="1290"
selection-end="1290" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
+ <file leaf-file-name="EntityManager.php" pinned="false"
current="false" current-in-tab="false">
+ <entry
file="file://$PROJECT_DIR$/application/providers/EntityManager.php">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="35" column="76" selection-start="1649"
selection-end="1649" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
<file leaf-file-name="Type.php" pinned="false" current="false"
current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/models/Type.php">
<provider selected="true" editor-type-id="text-editor">
@@ -58,7 +70,7 @@
<file leaf-file-name="Binder.php" pinned="false" current="false"
current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/configs/Binder.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="51" column="71" selection-start="2115"
selection-end="2115" vertical-scroll-proportion="0.0">
+ <state line="51" column="86" selection-start="2130"
selection-end="2130" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -76,16 +88,25 @@
<file leaf-file-name="Meaning.php" pinned="false" current="false"
current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/daos/Meaning.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="122" column="0" selection-start="4234"
selection-end="4234" vertical-scroll-proportion="0.0">
+ <state line="43" column="38" selection-start="1989"
selection-end="1989" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Meaning.php" pinned="false" current="false"
current-in-tab="false">
+ <entry
file="file://$PROJECT_DIR$/application/daos/interfaces/Meaning.php">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="55" column="2" selection-start="1989"
selection-end="1989" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="Meaning.php" pinned="false" current="true"
current-in-tab="true">
<entry
file="file://$PROJECT_DIR$/application/services/Meaning.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="120" column="60" selection-start="3502"
selection-end="3502" vertical-scroll-proportion="0.0">
+ <state line="130" column="0" selection-start="3866"
selection-end="3866" vertical-scroll-proportion="0.38505095">
<folding />
</state>
</provider>
@@ -140,13 +161,13 @@
<option value="$PROJECT_DIR$/application/utilities/REST.php" />
<option value="$PROJECT_DIR$/application/daos/Type.php" />
<option
value="$PROJECT_DIR$/application/modules/cpanel/controllers/EntriController.php"
/>
- <option
value="$PROJECT_DIR$/application/daos/interfaces/Meaning.php" />
<option value="$PROJECT_DIR$/application/models/Meaning.php" />
<option value="$PROJECT_DIR$/application/models/Type.php" />
+ <option
value="$PROJECT_DIR$/public/javascripts/cpanel/modules/entry/forms/Type.js"
/>
+ <option value="$PROJECT_DIR$/application/configs/Binder.php" />
<option value="$PROJECT_DIR$/application/daos/Meaning.php" />
+ <option
value="$PROJECT_DIR$/application/daos/interfaces/Meaning.php" />
<option value="$PROJECT_DIR$/application/services/Meaning.php" />
- <option value="$PROJECT_DIR$/application/configs/Binder.php" />
- <option
value="$PROJECT_DIR$/public/javascripts/cpanel/modules/entry/forms/Type.js"
/>
</list>
</option>
</component>
@@ -606,24 +627,6 @@
<option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
- <PATH>
- <PATH_ELEMENT>
- <option name="myItemId" value="kateglo" />
- <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
- </PATH_ELEMENT>
- <PATH_ELEMENT>
- <option name="myItemId" value="kateglo" />
- <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
- </PATH_ELEMENT>
- <PATH_ELEMENT>
- <option name="myItemId" value="application" />
- <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
- </PATH_ELEMENT>
- <PATH_ELEMENT>
- <option name="myItemId" value="configs" />
- <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
- </PATH_ELEMENT>
- </PATH>
</subPane>
</pane>
<pane id="Favorites" />
@@ -732,7 +735,7 @@
<option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
<option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
<option name="FORCE_UPDATE" value="false" />
- <configuration
useDefault="true">C:\Users\Purnama\AppData\Roaming\Subversion</configuration>
+ <configuration
useDefault="true">C:\Users\purnamaa\AppData\Roaming\Subversion</configuration>
<myIsUseDefaultProxy>true</myIsUseDefaultProxy>
<supportedVersion>125</supportedVersion>
</component>
@@ -740,16 +743,16 @@
<option name="myMappingRoots">
<list>
<SvnCopyRootSimple>
- <option name="myVcsRoot"
value="C:\Users\Purnama\StormWorkspace\kateglo" />
- <option name="myCopyRoot"
value="C:\Users\Purnama\StormWorkspace\kateglo" />
+ <option name="myVcsRoot"
value="C:\PropDev\StormWorkspace\kateglo" />
+ <option name="myCopyRoot"
value="C:\PropDev\StormWorkspace\kateglo" />
</SvnCopyRootSimple>
</list>
</option>
<option name="myMoreRealMappingRoots">
<list>
<SvnCopyRootSimple>
- <option name="myVcsRoot"
value="C:\Users\Purnama\StormWorkspace\kateglo" />
- <option name="myCopyRoot"
value="C:\Users\Purnama\StormWorkspace\kateglo" />
+ <option name="myVcsRoot"
value="C:\PropDev\StormWorkspace\kateglo" />
+ <option name="myCopyRoot"
value="C:\PropDev\StormWorkspace\kateglo" />
</SvnCopyRootSimple>
</list>
</option>
@@ -789,8 +792,8 @@
<window_info id="Data Sources" active="false" anchor="right"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="3" side_tool="false"
content_ui="tabs" />
<window_info id="Changes" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.31712964" sideWeight="0.5" order="7" side_tool="false"
content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.3298611" sideWeight="0.5" order="6" side_tool="false"
content_ui="tabs" />
- <window_info id="Structure" active="false" anchor="left"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true"
weight="0.20833333" sideWeight="0.63986784" order="1" side_tool="true"
content_ui="tabs" />
- <window_info id="Project" active="true" anchor="left"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true"
weight="0.20833333" sideWeight="0.3524229" order="0" side_tool="false"
content_ui="tabs" />
+ <window_info id="Structure" active="false" anchor="left"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true"
weight="0.21367522" sideWeight="0.6464758" order="1" side_tool="true"
content_ui="tabs" />
+ <window_info id="Project" active="true" anchor="left"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true"
weight="0.21367522" sideWeight="0.34581497" order="0" side_tool="false"
content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.1632653" sideWeight="0.5" order="3" side_tool="false"
content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs"
/>
<window_info id="Event Log" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs"
/>
@@ -844,7 +847,7 @@
<option name="INCLUDE_TEXT_INTO_SHELF" value="false" />
<option name="CREATE_PATCH_EXPAND_DETAILS_DEFAULT" value="true" />
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
- <option name="LAST_COMMIT_MESSAGE" value="CPanel. update types" />
+ <option name="LAST_COMMIT_MESSAGE" value="Dependency Injection set up
singleton" />
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="true" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
@@ -857,7 +860,6 @@
<option name="UPDATE_GROUP_BY_CHANGELIST" value="false" />
<option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
<option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
- <MESSAGE value="Init CPanel Bug Fix&#10;" />
<MESSAGE value="Mock Ups&#10;" />
<MESSAGE value="Cpanel &amp; mock ups&#10;" />
<MESSAGE value="Cpanel bug fix&#10;" />
@@ -882,16 +884,12 @@
<MESSAGE value="Refactoring php solr client" />
<MESSAGE value="Refactoring zend framework" />
<MESSAGE value="CPanel. update types" />
+ <MESSAGE value="Dependency Injection set up singleton" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
</component>
<component name="editorHistoryManager">
- <entry
file="file://$PROJECT_DIR$/application/providers/EntityManager.php">
- <provider selected="true" editor-type-id="text-editor">
- <state line="91" column="39" selection-start="2654"
selection-end="2654" vertical-scroll-proportion="0.0" />
- </provider>
- </entry>
<entry
file="file://$PROJECT_DIR$/../stubbles/src/main/php/net/stubbles/lang/stubObject.php">
<provider selected="true" editor-type-id="text-editor">
<state line="16" column="10" selection-start="420"
selection-end="420" vertical-scroll-proportion="0.33242506" />
@@ -942,33 +940,49 @@
<state line="173" column="15" selection-start="4498"
selection-end="4498" vertical-scroll-proportion="0.0" />
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/application/configs/Binder.php">
+ <entry file="file://$PROJECT_DIR$/application/models/Meaning.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="51" column="71" selection-start="2115"
selection-end="2115" vertical-scroll-proportion="0.0" />
+ <state line="245" column="9" selection-start="6719"
selection-end="6719" vertical-scroll-proportion="0.0" />
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/application/models/Meaning.php">
+ <entry
file="file://$PROJECT_DIR$/public/javascripts/cpanel/modules/entry/forms/Type.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="245" column="9" selection-start="6719"
selection-end="6719" vertical-scroll-proportion="0.0" />
+ <state line="28" column="56" selection-start="1290"
selection-end="1290" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry
file="file://$PROJECT_DIR$/application/providers/EntityManager.php">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="35" column="76" selection-start="1649"
selection-end="1649" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/application/configs/Binder.php">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="51" column="86" selection-start="2130"
selection-end="2130" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/daos/Meaning.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="122" column="0" selection-start="4234"
selection-end="4234" vertical-scroll-proportion="0.0">
+ <state line="43" column="38" selection-start="1989"
selection-end="1989" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/application/services/Meaning.php">
+ <entry
file="file://$PROJECT_DIR$/application/daos/interfaces/Meaning.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="120" column="60" selection-start="3502"
selection-end="3502" vertical-scroll-proportion="0.0">
+ <state line="55" column="2" selection-start="1989"
selection-end="1989" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry
file="file://$PROJECT_DIR$/public/javascripts/cpanel/modules/entry/forms/Type.js">
+ <entry file="file://$PROJECT_DIR$/application/services/Meaning.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="28" column="56" selection-start="1302"
selection-end="1302" vertical-scroll-proportion="0.019252548">
+ <state line="130" column="0" selection-start="3866"
selection-end="3866" vertical-scroll-proportion="0.38505095">
<folding />
</state>
</provider>
=======================================
--- /branches/kateglox/application/configs/Binder.php Tue Jan 24 10:14:47
2012
+++ /branches/kateglox/application/configs/Binder.php Wed Jan 25 08:41:07
2012
@@ -49,12 +49,12 @@
public static function bind(\stubBinder $container)
{

- $container->bind('Zend_Log')->toProviderClass(Log::$CLASS_NAME);
-
$container->bind('Zend_Config')->toProviderClass(Config::$CLASS_NAME);
-
$container->bind('Apache_Solr_Service')->toProviderClass(Solr::$CLASS_NAME);
-
$container->bind('Doctrine\DBAL\Driver\Connection')->toProviderClass(Connection::$CLASS_NAME);
-
$container->bind('Doctrine\ORM\EntityManager')->toProviderClass(EntityManager::$CLASS_NAME);
-
$container->bind('Doctrine\Common\Cache\Cache')->to('Doctrine\Common\Cache\ApcCache');
+
$container->bind('Zend_Log')->toProviderClass(Log::$CLASS_NAME)->asSingleton();
+
$container->bind('Zend_Config')->toProviderClass(Config::$CLASS_NAME)->asSingleton();
+
$container->bind('Apache_Solr_Service')->toProviderClass(Solr::$CLASS_NAME)->asSingleton();
+
$container->bind('Doctrine\DBAL\Driver\Connection')->toProviderClass(Connection::$CLASS_NAME)->asSingleton();
+
$container->bind('Doctrine\ORM\EntityManager')->toProviderClass(EntityManager::$CLASS_NAME)->asSingleton();
+
$container->bind('Doctrine\Common\Cache\Cache')->to('Doctrine\Common\Cache\ApcCache')->asSingleton();

$container->bind('Zend_Controller_Dispatcher_Interface')->to('Zend_Controller_Dispatcher_Stubbles');

$container->bind(daos\interfaces\Entry::INTERFACE_NAME)->to(daos\Entry::$CLASS_NAME);

$container->bind(daos\interfaces\Search::INTERFACE_NAME)->to(daos\Search::$CLASS_NAME);
=======================================
--- /branches/kateglox/application/daos/Meaning.php Tue Jan 24 10:14:47 2012
+++ /branches/kateglox/application/daos/Meaning.php Wed Jan 25 08:41:07 2012
@@ -94,35 +94,6 @@
throw new DomainStateException("Wrong State!");
}
}
-
- /**
- * @param $id
- * @param $version
- * @param array $types
- * @return \kateglo\application\models\Meaning
- * @throws exceptions\DomainStateException
- */
- public function updateTypes($id, $version, array $types)
- {
- $meaning = $this->getById($id, $version);
- /** @var $type \kateglo\application\models\Type */
- foreach ($meaning->getTypes() as $type) {
- if (in_array($type->getId(), $types)) {
- foreach (array_keys($types, $type->getId()) as $key) {
- unset($types[$key]);
- }
- } else {
- $meaning->removeType($type);
- }
- }
- foreach ($types as $typeId) {
- $type = $this->entityManager->find(models\Type::CLASS_NAME,
$typeId);
- $meaning->addType($type);
- }
- $this->update($meaning);
-
- return $meaning;
- }
}

?>
=======================================
--- /branches/kateglox/application/daos/interfaces/Meaning.php Tue Jan 24
10:14:47 2012
+++ /branches/kateglox/application/daos/interfaces/Meaning.php Wed Jan 25
08:41:07 2012
@@ -51,15 +51,6 @@
* @return \kateglo\application\daos\interfaces\Meaning
*/
function update(models\Meaning $meaning);
-
- /**
- * @abstract
- * @param $id
- * @param $version
- * @param array $types
- * @return \kateglo\application\models\Meaning
- */
- function updateTypes($id, $version, array $types);
}

?>
=======================================
--- /branches/kateglox/application/services/Meaning.php Tue Jan 24 10:14:47
2012
+++ /branches/kateglox/application/services/Meaning.php Wed Jan 25 08:41:07
2012
@@ -73,7 +73,7 @@

/**
*
- * @params \kateglo\application\daos\interfaces\Meaning $meaning
+ * @params \kateglo\application\daos\interfaces\Type $type
* @return void
*
* @Inject
@@ -99,6 +99,7 @@
/**
* @param $id
* @param null $version
+ * @return \kateglo\application\models\Meaning
* @throws exceptions\IllegalTypeException
*/
public function getById($id, $version = null)
@@ -114,9 +115,10 @@
}

/**
- * @param $meaningId
- * @param $meaningVersion
+ * @param $id
+ * @param $version
* @param array $types
+ * @return \kateglo\application\models\Meaning
*/
public function updateTypes($id, $version, array $types)
{
@@ -126,7 +128,23 @@
if (!is_numeric($version)) {
throw new IllegalTypeException('Meaning Version: "' .
$version . '" is Not Numeric');
}
- $meaning = $this->meaning->updateTypes($id, $version, $types);
+
+ $meaning = $this->meaning->getById($id, $version);
+ /** @var $type \kateglo\application\models\Type */
+ foreach ($meaning->getTypes() as $type) {
+ if (in_array($type->getId(), $types)) {
+ foreach (array_keys($types, $type->getId()) as $key) {
+ unset($types[$key]);
+ }
+ } else {
+ $meaning->removeType($type);
+ }
+ }
+ foreach ($types as $typeId) {
+ $type = $this->type->getById($typeId);
+ $meaning->addType($type);
+ }
+ $this->meaning->update($meaning);
$this->search->update($meaning->getEntry());
return $meaning;
}

Reply all
Reply to author
Forward
0 new messages