{ES} - 3.6.2 Creando Componentes a medida
Supongamos que nuestra aplicación online necesita efectuar una compleja operación matemática en muchas partes de la aplicación. Creariamos un componente que albergara esa lógica compartida para poder ser usada en diferentes controladores
El primer paso es crear una nueva clase y fichero de componente. Crea el fichero en /app/controllers/components/math.php. La estructura básica para el componente quedaría así.
<?php
class MathComponent extends Object {
function doComplexOperation($amount1, $amount2) {
return $amount1 + $amount2;
}
}
?>
<?phpclass MathComponent extends Object {function doComplexOperation($amount1, $amount2) {return $amount1 + $amount2;}}?>
{EN} - 3.6.2 Creating Custom Components
Suppose our online application needs to perform a complex mathematical operation in many different parts of the application. We could create a component to house this shared logic for use in many different controllers.
The first step is to create a new component file and class. Create the file in /app/controllers/components/math.php. The basic structure for the component would look something like this.
<?php
class MathComponent extends Object {
function doComplexOperation($amount1, $amount2) {
return $amount1 + $amount2;
}
}
?>
<?phpclass MathComponent extends Object {function doComplexOperation($amount1, $amount2) {return $amount1 + $amount2;}}?>
Diferencias
| Lines: 1-10 | Lines: 1-10 | ||
| - | <title>Creating Custom Components</title> | + | <title>Creando Componentes a medida</title> |
| <p> | <p> | ||
| - | Suppose our online application needs to perform a complex mathematical operation in many different parts of the application. We could create a component to house this shared logic for use in many different controllers. | + | Supongamos que nuestra aplicación online necesita efectuar una compleja operación matemática en muchas partes de la aplicación. Creariamos un componente que albergara esa lógica compartida para poder ser usada en diferentes controladores |
| </p> | </p> | ||
| <p> | <p> | ||
| - | The first step is to create a new component file and class. Create the file in /app/controllers/components/math.php. The basic structure for the component would look something like this. | + | El primer paso es crear una nueva clase y fichero de componente. Crea el fichero en /app/controllers/components/math.php. La estructura básica para el componente quedaría así. |
| </p> | </p> | ||
| <pre> | <pre> | ||
| <?php | <?php | ||
