/**
  * @param string $method
  * @param array $args
  * @return mixed
  */
 public function callResourceMethod($method, $args)
 {
     $resource = $this->getResource();
     if ($this->inTransaction || Resource::isWriteQuery($method, $args)) {
         $resource = $this->getWriteResource();
     }
     $capture = false;
     if (\Pimcore::inAdmin()) {
         $methodsToCheck = array("query", "update", "delete", "insert");
         if (in_array($method, $methodsToCheck)) {
             $capture = true;
             Resource::startCapturingDefinitionModifications($resource, $method, $args);
         }
     }
     $r = call_user_func_array(array($resource, $method), $args);
     if (\Pimcore::inAdmin() && $capture) {
         Resource::stopCapturingDefinitionModifications($resource);
     }
     return $r;
 }