[TASK] Simplify propertyName-creation
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 12 Apr 2013 20:12:07 +0000 (22:12 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Fri, 12 Apr 2013 20:18:04 +0000 (22:18 +0200)
Since PHP 5.3.0 function lcfirst() exists.

Resolves: #47171
Releases: 6.0, 6.1
Change-Id: I314ee3c14683283dc000daad41693294c12c62d2
Reviewed-on: https://review.typo3.org/19870
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
typo3/sysext/extbase/Classes/Persistence/Repository.php

index 96a5167..1c8302d 100644 (file)
@@ -396,17 +396,17 @@ class Repository implements \TYPO3\CMS\Extbase\Persistence\RepositoryInterface,
         */
        public function __call($methodName, $arguments) {
                if (substr($methodName, 0, 6) === 'findBy' && strlen($methodName) > 7) {
-                       $propertyName = strtolower(substr(substr($methodName, 6), 0, 1)) . substr(substr($methodName, 6), 1);
+                       $propertyName = lcfirst(substr($methodName, 6));
                        $query = $this->createQuery();
                        $result = $query->matching($query->equals($propertyName, $arguments[0]))->execute();
                        return $result;
                } elseif (substr($methodName, 0, 9) === 'findOneBy' && strlen($methodName) > 10) {
-                       $propertyName = strtolower(substr(substr($methodName, 9), 0, 1)) . substr(substr($methodName, 9), 1);
+                       $propertyName = lcfirst(substr($methodName, 9));
                        $query = $this->createQuery();
                        $object = $query->matching($query->equals($propertyName, $arguments[0]))->setLimit(1)->execute()->getFirst();
                        return $object;
                } elseif (substr($methodName, 0, 7) === 'countBy' && strlen($methodName) > 8) {
-                       $propertyName = strtolower(substr(substr($methodName, 7), 0, 1)) . substr(substr($methodName, 7), 1);
+                       $propertyName = lcfirst(substr($methodName, 7));
                        $query = $this->createQuery();
                        $result = $query->matching($query->equals($propertyName, $arguments[0]))->execute()->count();
                        return $result;