Created
September 12, 2010 14:14
-
-
Save v6ak/576143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PHP fragment | |
// Code creates a multicomponent in Nette. The code is a bit ugly. | |
protected function createComponent($name){ | |
$PFX = 'rating'; | |
$PFXLEN = strlen($PFX); | |
if(substr($name, 0, $PFXLEN === $PFX){ | |
return $this->createRating($name, substr($name, $PFXLEN)); | |
} | |
return parent::createComponent($name); | |
} | |
private function createRating($name, $id){ | |
return new RatingControl($this, $name, $id); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PHP fragment | |
// This does not work, it is just an idea how it can work. | |
// Note that it probably can be simply implemented. | |
protected function createComponentRating($name){ | |
return new MultiComponent(function($c, $name, $id){ | |
return new RatingControl($c, $name, $id); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PHP fragment | |
// This does not work, it is just an idea how it can work. | |
protected function createMultiComponentRating($name, $id){ | |
return new RatingControl($this, $name, $id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment