コード例 #1
0
 /**
  * Get the value for a static variable.
  * @param $className The data class, as specified in your fixture file.  Parent classes won't work
  * @param $identifier The identifier string, as provided in your fixture file
  * @param $subIdentifier A secondary identifier string, as provided in your fixture file
  * @return Mixed
  * @TODO: implement subIdentfier
  */
 public function getStaticValue($className, $identifier, $subIdentifier = null)
 {
     //this only runs once
     if (!count($this->fixtureDictionary)) {
         $this->loadData();
     }
     if ($subIdentifier) {
         if (isset($this->fixtureDictionary[$className][$identifier][$subIdentifier])) {
             return $this->fixtureDictionary[$className][$identifier][$subIdentifier];
         }
     } elseif (isset($this->fixtureDictionary[$className][$identifier])) {
         return $this->fixtureDictionary[$className][$identifier];
     }
     if (Director::isDev()) {
         echo "Please add the following line to one of these files : <br />\n\t\t\t" . implode(", ", self::$folder_and_file_locations) . "<br />\n\t\t\t<pre>\n{$className}:\n\t {$identifier}: [check default configuration (ecommerce/_config/ecommerce.yaml) for example value]\n\t\t\t</pre><br />\n\t\t\tPlease also make sure to visit <a href=\"/dev/ecommerce/\">/dev/ecommerce/</a> to check all your configurations and run any migration scripts!";
         user_error("Could not find definition for: {$className}.{$identifier}.{$subIdentifier} in " . implode(", ", self::$folder_and_file_locations), E_USER_NOTICE);
     }
     //when in live mode, try to keep the boat floating.
     if (Director::isLive()) {
         $realFiles = self::$folder_and_file_locations;
         $backupFiles = "ecommerce/_config/ecommerce.yaml";
         if ($realFiles != $backupFiles) {
             self::$folder_and_file_locations = $backupFiles;
             $outcome = self::getStaticValue($className, $identifier, $subIdentifier);
             self::$folder_and_file_locations = $realFiles;
             return $outcome;
         }
     }
     return null;
 }