Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created Sep 12, 2010
Embed
What would you like to do?
<?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);
}
<?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);
});
}
<?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