<commit_before><?php echo '<?php'?>


class <?php echo $controller_class_name?> extends ApplicationController
{
<?php 
    if($model_name != $controller_name){ // if equal will be handled by the Akelos directly
        echo "    var \$models = '$singular_name';\n\n";
    }
?>
    function index()
    {
        $this->renderAction('listing');
    }

<?php  foreach((array)@$actions as $action) :?>
    function <?php echo $action?>()
    {
    }

<?php  endforeach; ?>
    function listing()
    {
        $this-><?php echo $singular_name?>_pages = $this->pagination_helper->getPaginator($this-><?php echo $model_name?>, array('items_per_page' => 10));        
        $this-><?php echo $plural_name?> = $this-><?php echo $model_name?>->find('all', $this->pagination_helper->getFindOptions($this-><?php echo $model_name?>));
    }

    function show()
    {
        $this-><?php echo $singular_name?> = $this-><?php echo $model_name?>->find(@$this->params['id']);
    }

    function add()
    {
        if(!empty($this->params['<?php echo $singular_name?>'])){
            $this-><?php echo $model_name?>->setAttributes($this->params['<?php echo $singular_name?>']);
            if ($this->Request->isPost() && $this-><?php echo $model_name?>->save()){
                $this->flash['notice'] = $this->t('<?php echo $model_name?> was successfully created.');
                $this->redirectTo(array('action' => 'show', 'id' => $this-><?php echo $model_name?>->getId()));
            }
        }
    }
    <?php  if($model_name != $controller_name){ ?>

    function edit()
    {
        if(!empty($this->params['id'])){
            if(empty($this-><?php echo $singular_name?>->id) || $this-><?php echo $singular_name?>->id != $this->params['id']){
                $this-><?php echo $singular_name?> =& $this-><?php echo $model_name?>->find($this->params['id']);
            }
        }else{
            $this->redirectToAction('listing');
        }

        if(!empty($this->params['<?php echo $singular_name?>'])){
            $this-><?php echo $singular_name?>->setAttributes($this->params['<?php echo $singular_name?>']);
            if($this->Request->isPost() && $this-><?php echo $singular_name?>->save()){
                $this->flash['notice'] = $this->t('<?php echo $model_name?> was successfully updated.');
                $this->redirectTo(array('action' => 'show', 'id' => $this-><?php echo $singular_name?>->getId()));
            }
        }
    }
    <?php } else { ?>

    function edit()
    {
        if (empty($this->params['id'])){
         $this->redirectToAction('listing');
        }
        if(!empty($this->params['<?php echo $singular_name?>']) && !empty($this->params['id'])){
            $this-><?php echo $singular_name?>->setAttributes($this->params['<?php echo $singular_name?>']);
            if($this->Request->isPost() && $this-><?php echo $singular_name?>->save()){
                $this->flash['notice'] = $this->t('<?php echo $model_name?> was successfully updated.');
                $this->redirectTo(array('action' => 'show', 'id' => $this-><?php echo $singular_name?>->getId()));
            }
        }
    }
    <?php } ?>
    
    function destroy()
    {
        if(!empty($this->params['id'])){
            $this-><?php echo $singular_name?> = $this-><?php echo $model_name?>->find($this->params['id']);
            if($this->Request->isPost()){
                $this-><?php echo $singular_name?>->destroy();
                $this->redirectTo(array('action' => 'listing'));
            }
        }
    }  
}

?><commit_msg>Fixing scaffold template for instantiating found models as references on PHP4. Fixes #30<commit_after><?php echo '<?php'?>


class <?php echo $controller_class_name?> extends ApplicationController
{
<?php 
    if($model_name != $controller_name){ // if equal will be handled by the Akelos directly
        echo "    var \$models = '$singular_name';\n\n";
    }
?>
    function index()
    {
        $this->renderAction('listing');
    }

<?php  foreach((array)@$actions as $action) :?>
    function <?php echo $action?>()
    {
    }

<?php  endforeach; ?>
    function listing()
    {
        $this-><?php echo $singular_name?>_pages = $this->pagination_helper->getPaginator($this-><?php echo $model_name?>, array('items_per_page' => 10));        
        $this-><?php echo $plural_name?> =& $this-><?php echo $model_name?>->find('all', $this->pagination_helper->getFindOptions($this-><?php echo $model_name?>));
    }

    function show()
    {
        $this-><?php echo $singular_name?> =& $this-><?php echo $model_name?>->find(@$this->params['id']);
    }

    function add()
    {
        if(!empty($this->params['<?php echo $singular_name?>'])){
            $this-><?php echo $model_name?>->setAttributes($this->params['<?php echo $singular_name?>']);
            if ($this->Request->isPost() && $this-><?php echo $model_name?>->save()){
                $this->flash['notice'] = $this->t('<?php echo $model_name?> was successfully created.');
                $this->redirectTo(array('action' => 'show', 'id' => $this-><?php echo $model_name?>->getId()));
            }
        }
    }
    <?php  if($model_name != $controller_name){ ?>

    function edit()
    {
        if(!empty($this->params['id'])){
            if(empty($this-><?php echo $singular_name?>->id) || $this-><?php echo $singular_name?>->id != $this->params['id']){
                $this-><?php echo $singular_name?> =& $this-><?php echo $model_name?>->find($this->params['id']);
            }
        }else{
            $this->redirectToAction('listing');
        }

        if(!empty($this->params['<?php echo $singular_name?>'])){
            $this-><?php echo $singular_name?>->setAttributes($this->params['<?php echo $singular_name?>']);
            if($this->Request->isPost() && $this-><?php echo $singular_name?>->save()){
                $this->flash['notice'] = $this->t('<?php echo $model_name?> was successfully updated.');
                $this->redirectTo(array('action' => 'show', 'id' => $this-><?php echo $singular_name?>->getId()));
            }
        }
    }
    <?php } else { ?>

    function edit()
    {
        if (empty($this->params['id'])){
         $this->redirectToAction('listing');
        }
        if(!empty($this->params['<?php echo $singular_name?>']) && !empty($this->params['id'])){
            $this-><?php echo $singular_name?>->setAttributes($this->params['<?php echo $singular_name?>']);
            if($this->Request->isPost() && $this-><?php echo $singular_name?>->save()){
                $this->flash['notice'] = $this->t('<?php echo $model_name?> was successfully updated.');
                $this->redirectTo(array('action' => 'show', 'id' => $this-><?php echo $singular_name?>->getId()));
            }
        }
    }
    <?php } ?>
    
    function destroy()
    {
        if(!empty($this->params['id'])){
            $this-><?php echo $singular_name?> =& $this-><?php echo $model_name?>->find($this->params['id']);
            if($this->Request->isPost()){
                $this-><?php echo $singular_name?>->destroy();
                $this->redirectTo(array('action' => 'listing'));
            }
        }
    }  
}

?>
{'fraction_non_alphanumeric': 0.22313019390581718, 'fraction_numerical': 0.0009695290858725762, 'mean_word_length': 2.7145061728395063, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 259, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2397377', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2176, 'n_words': 388}