Skip to content

Commit

Permalink
class aliases are loaded on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 9, 2020
1 parent 752a2d4 commit 3a38709
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
"nette/latte": "<2.4"
},
"autoload": {
"classmap": ["src/"],
"files": ["src/compatibility.php"]
"classmap": ["src/"]
},
"minimum-stability": "dev",
"extra": {
Expand Down
3 changes: 3 additions & 0 deletions src/Application/UI/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,6 @@ public function offsetUnset($name)
}
}
}


class_exists(PresenterComponent::class);
3 changes: 3 additions & 0 deletions src/Application/UI/ComponentReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,6 @@ public function __call($name, $args)
Nette\Utils\ObjectMixin::strictCall(get_class($this), $name);
}
}


class_exists(PresenterComponentReflection::class);
21 changes: 19 additions & 2 deletions src/compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,22 @@
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/

class_alias('Nette\Application\UI\Component', 'Nette\Application\UI\PresenterComponent');
class_alias('Nette\Application\UI\ComponentReflection', 'Nette\Application\UI\PresenterComponentReflection');
namespace Nette\Application\UI;

if (false) {
/** @deprecated use Nette\Application\UI\Component */
class PresenterComponent
{
}
} elseif (!class_exists(PresenterComponent::class)) {
class_alias(Component::class, PresenterComponent::class);
}

if (false) {
/** @deprecated use Nette\Application\UI\ComponentReflection */
class PresenterComponentReflection
{
}
} elseif (!class_exists(PresenterComponentReflection::class)) {
class_alias(ComponentReflection::class, PresenterComponentReflection::class);
}

0 comments on commit 3a38709

Please sign in to comment.